ListBoxItem.Unselected 事件

定义

在取消选择 ListBoxItem 时发生。

public:
 event System::Windows::RoutedEventHandler ^ Unselected;
public event System.Windows.RoutedEventHandler Unselected;
member this.Unselected : System.Windows.RoutedEventHandler 
Public Custom Event Unselected As RoutedEventHandler 

事件类型

示例

以下示例演示如何订阅和处理此事件。

<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.";
    }
}
Private Sub OnUnselected(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim lbi As ListBoxItem = TryCast(e.Source, ListBoxItem)

    If lbi IsNot Nothing Then
        label1.Content = lbi.Content.ToString() & " is unselected."
    End If
End Sub

注解

若要了解所选内容何时 ListBox 发生更改,请侦 SelectionChanged 听 事件。

路由事件信息

标识符字段 UnselectedEvent
路由策略 鼓 泡
委托 RoutedEventHandler

适用于