Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 2.43 KB

selector_selecteditem.md

File metadata and controls

39 lines (26 loc) · 2.43 KB
-api-id -api-type
P:Windows.UI.Xaml.Controls.Primitives.Selector.SelectedItem
winrt property

Windows.UI.Xaml.Controls.Primitives.Selector.SelectedItem

-description

Gets or sets the selected item.

-xaml-syntax

<selector SelectedItem="bindingReference" .../>

-xaml-values

bindingReference
bindingReferenceA data binding reference to a specific item from the data collection that populates the selector control. Usually the list as a whole is bound to a data context, and the binding for the selected item adds a path or qualifier to return just one item.
## -property-value The selected item. The default is null.

-remarks

Some controls that are derived from Selector, like ListBox, ListView, and GridView, also support multi-selection. When multi-selection is enabled in those controls, use their SelectedItems property to get the selected item collection.

Selection behavior and CollectionViewSource

List controls that derive from Selector have a default selection behavior that depends on what the items source is (the type that's used for ItemsSource). If the items source is a CollectionViewSource instance, then the behavior in the selection control is that the selection will default to the current item. When the list is first displayed, the selection defaults to the first item as current item. If you don't want the first item to be selected in this case, set IsSynchronizedWithCurrentItem to false in the GridView, the ListView, or other Selector-based control that is showing the selection.

-examples

-see-also

ListBox.SelectionMode, ListBox.SelectedItems, ListViewBase.SelectionMode, ListViewBase.SelectedItems