ListBoxItem.Selected Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when a ListBoxItem is selected.
public:
event System::Windows::RoutedEventHandler ^ Selected;
public event System.Windows.RoutedEventHandler Selected;
member this.Selected : System.Windows.RoutedEventHandler
Public Custom Event Selected As RoutedEventHandler
Event Type
Examples
The following example shows how to subscribe to and handle this event.
<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
Remarks
To know when the selection in a ListBox changes, listen for the SelectionChanged event.
Routed Event Information
Item | Value |
---|---|
Identifier field | SelectedEvent |
Routing strategy | Bubbling |
Delegate | RoutedEventHandler |
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET