Class ListBox
An ItemsControl in which individual items can be selected.
[TemplatePart("PART_ScrollViewer", typeof(IScrollable))]
public class ListBox : SelectingItemsControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider
- Inheritance
-
ListBox
- Implements
- Inherited Members
- Extension Methods
Constructors
ListBox()
public ListBox()
Fields
ScrollProperty
Defines the Scroll property.
public static readonly DirectProperty<ListBox, IScrollable?> ScrollProperty
Field Value
SelectedItemsProperty
Defines the SelectedItems property.
public static readonly DirectProperty<SelectingItemsControl, IList?> SelectedItemsProperty
Field Value
SelectionModeProperty
Defines the SelectionMode property.
public static readonly StyledProperty<SelectionMode> SelectionModeProperty
Field Value
SelectionProperty
Defines the Selection property.
public static readonly DirectProperty<SelectingItemsControl, ISelectionModel> SelectionProperty
Field Value
Properties
Scroll
Gets the scroll information for the ListBox.
public IScrollable? Scroll { get; }
Property Value
SelectedItems
public IList? SelectedItems { get; set; }
Property Value
Selection
public ISelectionModel Selection { get; set; }
Property Value
SelectionMode
Gets or sets the selection mode.
public SelectionMode SelectionMode { get; set; }
Property Value
Remarks
Note that the selection mode only applies to selections made via user interaction. Multiple selections can be made programmatically regardless of the value of this property.
Methods
CreateContainerForItemOverride(object?, int, object?)
Creates or a container that can be used to display an item.
protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)
Parameters
Returns
NeedsContainerOverride(object?, int, out object?)
Determines whether the specified item can be its own container.
protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)
Parameters
item
objectThe item to check.
index
intThe index of the item.
recycleKey
objectWhen the method returns, contains a key that can be used to locate a previously recycled container of the correct type, or null if the item cannot be recycled. If the item is its own container then by definition it cannot be recycled, so
recycleKey
shoud be set to null.
Returns
- bool
true if the item needs a container; otherwise false if the item can itself be used as a container.
OnApplyTemplate(TemplateAppliedEventArgs)
Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
Parameters
e
TemplateAppliedEventArgsThe event args.
OnKeyDown(KeyEventArgs)
Handles directional navigation within the ItemsControl.
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
KeyEventArgsThe key events.
SelectAll()
Selects all items in the ListBox.
public void SelectAll()
UnselectAll()
Deselects all items in the ListBox.
public void UnselectAll()