Class ListBox
Contains a list of selectable items.
Inheritance
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.dll
Syntax
[TemplatePart(Name = "ScrollViewer", Type = typeof(ScrollViewer))]
public class ListBox : Selector, IControl, IFrameworkElement, IUIElement, IDependencyObject
Constructors
| Improve this Doc View SourceListBox()
Initializes a new instance of the ListBox class.
Declaration
public ListBox()
Fields
| Improve this Doc View SourceIsSelectionActiveProperty
Identifies the IsSelectionActive dependency property.
Declaration
public static readonly DependencyProperty IsSelectionActiveProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
ItemContainerStyleProperty
Identifies the ItemContainerStyle dependency property.
Declaration
public static readonly DependencyProperty ItemContainerStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
SelectionModeProperty
Identifies the SelectionMode dependency property.
Declaration
public static readonly DependencyProperty SelectionModeProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Properties
| Improve this Doc View SourceHandlesScrolling
Gets a value that indicates whether a control supports scrolling.
Declaration
protected override bool HandlesScrolling { get; }
Property Value
Type | Description |
---|---|
System.Boolean | true if the control has a ScrollViewer in its style and has a custom keyboard scrolling behavior; otherwise, false. |
Overrides
| Improve this Doc View SourceItemContainerStyle
Gets or sets the style that is used when rendering the item containers.
Declaration
public Style ItemContainerStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The style applied to the item containers. The default is null. |
SelectedItems
Gets the list of currently selected items for the ListBox control.
Declaration
public IList SelectedItems { get; }
Property Value
Type | Description |
---|---|
System.Collections.IList | The list of currently selected items for the ListBox. |
SelectionMode
Gets or sets the selection behavior for the ListBox control.
Declaration
public SelectionMode SelectionMode { get; set; }
Property Value
Type | Description |
---|---|
SelectionMode | One of the SelectionMode values. |
Methods
| Improve this Doc View SourceGetContainerForItemOverride()
Creates or identifies the element used to display a specified item.
Declaration
protected override DependencyObject GetContainerForItemOverride()
Returns
Type | Description |
---|---|
DependencyObject | A ListBoxItem corresponding to a specified item. |
Overrides
| Improve this Doc View SourceIsItemItsOwnContainerOverride(Object)
Determines if the specified item is (or is eligible to be) its own item container.
Declaration
protected override bool IsItemItsOwnContainerOverride(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The specified item. |
Returns
Type | Description |
---|---|
System.Boolean | true if the item is its own item container; otherwise, false. |
Overrides
| Improve this Doc View SourceOnApplyTemplate()
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Returns a ListBoxAutomationPeer for the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A ListBoxAutomationPeer for the ListBox object. |
Overrides
| Improve this Doc View SourceOnGotFocus(RoutedEventArgs)
Called before the GotFocus event occurs.
Declaration
protected override void OnGotFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceOnKeyDown(KeyEventArgs)
Responds to the KeyDown event.
Declaration
protected override void OnKeyDown(KeyEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
KeyEventArgs | e | Provides data for KeyEventArgs. |
Overrides
| Improve this Doc View SourceOnLostFocus(RoutedEventArgs)
Called before the LostFocus event occurs.
Declaration
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
RoutedEventArgs | e | The data for the event. |
Overrides
| Improve this Doc View SourceScrollIntoView(Object)
Causes the object to scroll into view.
Declaration
public void ScrollIntoView(object item)
Parameters
Type | Name | Description |
---|---|---|
System.Object | item | The object to scroll. |
SelectAll()
Selects all the items in the ListBox.
Declaration
public void SelectAll()
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | SelectionMode is set to Single |