ListBox.SelectedItems Property

Definition

Gets the currently selected items.

[System.ComponentModel.Bindable(true)]
public System.Collections.IList SelectedItems { get; }

Property Value

Returns a collection of the currently selected items.

Attributes

Exceptions

Examples

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.";
    }
}

Remarks

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

製品 バージョン
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9