ListBoxItem.Selected Evento

Definición

Se produce cuando se selecciona ListBoxItem.

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

Tipo de evento

Ejemplos

En el ejemplo siguiente se muestra cómo suscribirse a este evento y controlarlo.

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

    if (lbi != null)
    {
        label1.Content = lbi.Content.ToString() + " is selected.";
    }
}
Private Sub OnSelected(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 selected."
    End If
End Sub

Comentarios

Para saber cuándo cambia la selección de un ListBox , escuche el SelectionChanged evento .

Información sobre eventos enrutados

Campo identificador SelectedEvent
Estrategia de enrutamiento Burbujeante
Delegado RoutedEventHandler

Se aplica a