Selector Selector Selector Class

Definition

Represents a control that enables a user to select an item from a collection of items.

public class Selector : ItemsControl, ISelectorpublic class Selector : ItemsControl, ISelectorPublic Class Selector Inherits ItemsControl Implements ISelector
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Remarks

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.

Selector derived classes

Selector is the parent class for these controls:

Note

SemanticZoom is a similar control but it doesn't enable selection itself. SemanticZoom inherits directly from Control . A SemanticZoom typically displays one of the Selector derived controls in each of its views.

Properties

IsSynchronizedWithCurrentItem IsSynchronizedWithCurrentItem IsSynchronizedWithCurrentItem

Gets or sets a value that indicates whether a Selector should keep the SelectedItem synchronized with the current item in the Items property.

public IReference<bool> IsSynchronizedWithCurrentItem { get; set; }public IReference<bool> IsSynchronizedWithCurrentItem { get; set; }Public ReadWrite Property IsSynchronizedWithCurrentItem As IReference<bool>
<selector IsSynchronizedWithCurrentItem="bool"/>
- or -
<selector IsSynchronizedWithCurrentItem="{x:Null}"/>
Value

true if the SelectedItem is always synchronized with the current item in the ItemCollection; false if the SelectedItem is never synchronized with the current item; null if the SelectedItem is synchronized with the current item only if the Selector uses an ICollectionView. The default value is null/indeterminate.

If you are programming using C#or Microsoft Visual Basic, the type of this property is projected as bool?(a nullable Boolean).

Attributes

Remarks

The nullable value for IsSynchronizedWithCurrentItem enables the value to be indeterminate, neither true nor false. This is indicated by a value of null if accessed in code. To set the value to null in XAML, use the {x:Null} markup extension.

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.

See Also

IsSynchronizedWithCurrentItemProperty IsSynchronizedWithCurrentItemProperty IsSynchronizedWithCurrentItemProperty

Identifies the IsSynchronizedWithCurrentItem dependency property.

public static DependencyProperty IsSynchronizedWithCurrentItemProperty { get; }public static DependencyProperty IsSynchronizedWithCurrentItemProperty { get; }Public Static ReadOnly Property IsSynchronizedWithCurrentItemProperty As DependencyProperty
Attributes

SelectedIndex SelectedIndex SelectedIndex

Gets or sets the index of the selected item.

public int SelectedIndex { get; set; }public int SelectedIndex { get; set; }Public ReadWrite Property SelectedIndex As int
<selector SelectedIndex="int" .../>
Value
int int int

The index of the selected item. The default is -1.

Attributes

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.

SelectedIndexProperty SelectedIndexProperty SelectedIndexProperty

Identifies the SelectedIndex dependency property.

public static DependencyProperty SelectedIndexProperty { get; }public static DependencyProperty SelectedIndexProperty { get; }Public Static ReadOnly Property SelectedIndexProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the SelectedIndex dependency property.

Attributes

SelectedItem SelectedItem SelectedItem

Gets or sets the selected item.

public object SelectedItem { get; set; }public object SelectedItem { get; set; }Public ReadWrite Property SelectedItem As object
<selector SelectedItem="bindingReference" .../>
Value
object object object

The selected item. The default is null.

Attributes

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.

SelectedItemProperty SelectedItemProperty SelectedItemProperty

Identifies the SelectedItem dependency property.

public static DependencyProperty SelectedItemProperty { get; }public static DependencyProperty SelectedItemProperty { get; }Public Static ReadOnly Property SelectedItemProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the SelectedItem dependency property.

Attributes

SelectedValue SelectedValue SelectedValue

Gets or sets the value of the selected item, obtained by using the SelectedValuePath.

public object SelectedValue { get; set; }public object SelectedValue { get; set; }Public ReadWrite Property SelectedValue As object
<selector SelectedValue="valueAsString"/>
Value
object object object

The value of the selected item, obtained by using the SelectedValuePath, or null if no item is selected. The default value is null.

Attributes

SelectedValuePath SelectedValuePath SelectedValuePath

Gets or sets the property path that is used to get the SelectedValue property of the SelectedItem property.

public string SelectedValuePath { get; set; }public string SelectedValuePath { get; set; }Public ReadWrite Property SelectedValuePath As string
<selector SelectedValuePath="propertyPath"/>
Value
string string string

The property path that is used to get the SelectedValue property of the SelectedItem property. The default is String.Empty.

Attributes

SelectedValuePathProperty SelectedValuePathProperty SelectedValuePathProperty

Gets the identifier for the SelectedValuePath dependency property.

public static DependencyProperty SelectedValuePathProperty { get; }public static DependencyProperty SelectedValuePathProperty { get; }Public Static ReadOnly Property SelectedValuePathProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the SelectedValuePath dependency property.

Attributes

SelectedValueProperty SelectedValueProperty SelectedValueProperty

Gets the identifier for the SelectedValue dependency property.

public static DependencyProperty SelectedValueProperty { get; }public static DependencyProperty SelectedValueProperty { get; }Public Static ReadOnly Property SelectedValueProperty As DependencyProperty
Value
DependencyProperty DependencyProperty DependencyProperty

The identifier for the SelectedValue dependency property.

Attributes

Methods

GetIsSelectionActive(DependencyObject) GetIsSelectionActive(DependencyObject) GetIsSelectionActive(DependencyObject)

Gets a value that indicates whether the specified Selector has the focus.

public static bool GetIsSelectionActive(DependencyObject element)public static bool GetIsSelectionActive(DependencyObject element)Public Static Function GetIsSelectionActive(element As DependencyObject) As bool
Parameters
Returns
bool bool bool

true to indicate that the Selector has the focus; otherwise, false.

Attributes

Events

SelectionChanged SelectionChanged SelectionChanged

Occurs when the currently selected item changes.

public event SelectionChangedEventHandler SelectionChangedpublic event SelectionChangedEventHandler SelectionChangedPublic Event SelectionChanged
<selector SelectionChanged="eventhandler"/>
Attributes

Remarks

Note

For ListView and GridView: If the ItemsSource implements IItemsRangeInfo, and selection is modified using SelectRange or DeselectRange, the AddedItems and RemovedItems properties are not set in the SelectionChangedEventArgs. Setting these properties requires devirtualizing the item object. Use the SelectedRanges property to get the items instead.

See Also