ListBoxItem.Unselected Event

Definition

Occurs when a ListBoxItem is unselected.

C#
public event System.Windows.RoutedEventHandler Unselected;

Event Type

Examples

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

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

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

Remarks

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

Routed Event Information

Item Value
Identifier field UnselectedEvent
Routing strategy Bubbling
Delegate RoutedEventHandler

Applies to

Product Versions
.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, 10