ListBox.SelectedItems Property


Gets the currently selected items.

 property System::Collections::IList ^ SelectedItems { System::Collections::IList ^ get(); };
public System.Collections.IList SelectedItems { get; }
member this.SelectedItems : System.Collections.IList
Public ReadOnly Property SelectedItems As IList

Property Value

Returns a collection of the currently selected items.




The following example shows how to use the SelectedItems property to determine whether a list box has any selected items.

private void SelectedItems(object sender, RoutedEventArgs e)
    if (lb.SelectedItem != null)
        label1.Content = "Has " + (lb.SelectedItems.Count.ToString()) + " item(s) selected.";
Private Sub SelectedItems(ByVal sender As Object, ByVal e As RoutedEventArgs)
    If lb.SelectedItem IsNot Nothing Then
        label1.Content = "Has " & (lb.SelectedItems.Count.ToString()) & " item(s) selected."
    End If
End Sub


This property is meant to be used when SelectionMode does not equal Single. If the selection mode is Single the correct property to use is SelectedItem.

Dependency Property Information

Identifier field SelectedItemsProperty
Metadata properties set to true None

Applies to