Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ListBoxItem.Unselected Event

 

Occurs when a ListBoxItem is unselected.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public event RoutedEventHandler Unselected

To know when the selection in a ListBox changes, listen for the SelectionChanged event.

Identifier field

UnselectedEvent

Routing strategy

Bubbling

Delegate

RoutedEventHandler

The following examples show how to subscribe to and handle this event.

<ListBoxItem Name="lbi0" Selected="OnSelected" Unselected="OnUnselected">Item 0</ListBoxItem>
private void OnUnselected(object sender, RoutedEventArgs e)
{
    ListBoxItem lbi = e.Source as ListBoxItem;

    if (lbi != null)
    {
        label1.Content = lbi.Content.ToString() + " is unselected.";
    }
}

.NET Framework
Available since 3.0
Return to top
Show:
© 2017 Microsoft