Gets or sets the index of the first item in the current selection or returns negative one (-1) if the selection is empty.
Assembly: PresentationFramework (in PresentationFramework.dll)
If a Selector supports selecting a single item, the property returns the index of the selected item. If a Selector supports multiple selections, returns the index of the item that the user selected first.
Setting Selector that supports multiple selections clears existing selected items and sets the selection to the item specified by the index. returns -1 if selection is empty.in a
If you set ArgumentException is thrown. If you set to a value equal or greater than the number of child elements, the value is ignored.to a value less that -1, an
<ListBox Margin="10,0,0,5" SelectedIndex="1" Name="listBox1" VerticalAlignment="Top" Grid.Column="0" Grid.Row="4"> <ListBoxItem>Item 0</ListBoxItem> <ListBoxItem>Item 1</ListBoxItem> <ListBoxItem>Item 2</ListBoxItem> <ListBoxItem>Item 3</ListBoxItem> </ListBox>
The following example uses theproperty to determine whether the item at index 0 is the first item in the selection.
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0