TreeView.SelectedItemChanged 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 the SelectedItem changes.
public:
event System::Windows::RoutedPropertyChangedEventHandler<System::Object ^> ^ SelectedItemChanged;
public event System.Windows.RoutedPropertyChangedEventHandler<object> SelectedItemChanged;
member this.SelectedItemChanged : System.Windows.RoutedPropertyChangedEventHandler<obj>
Public Custom Event SelectedItemChanged As RoutedPropertyChangedEventHandler(Of Object)
Event Type
Examples
The following example shows how to specify an event handler for the SelectedItemChanged event.
<TreeView SelectedItemChanged="SelectionChanged">
<TreeViewItem Header="Employee1" IsSelected="True">
<TreeViewItem Header="Jesper"/>
<TreeViewItem Header="Aaberg"/>
<TreeViewItem Header="12345"/>
</TreeViewItem>
<TreeViewItem Header="Employee2">
<TreeViewItem Header="Dominik"/>
<TreeViewItem Header="Paiha"/>
<TreeViewItem Header="98765"/>
</TreeViewItem>
</TreeView>
The following example shows how to define the event handler.
private void SelectionChanged(object sender, RoutedPropertyChangedEventArgs<Object> e)
{
//Perform actions when SelectedItem changes
MessageBox.Show(((TreeViewItem) e.NewValue).Header.ToString());
}
Private Sub SelectionChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Object))
'Perform actions when SelectedItem changes
MessageBox.Show((CType(e.NewValue, TreeViewItem)).Header.ToString())
End Sub
Remarks
Routed Event Information
Identifier Field | SelectedItemChangedEvent |
Routing Strategy | Bubbling |
Delegate | RoutedPropertyChangedEventHandler<T> |
XAML Attribute Usage
<object SelectedItemChanged="RoutedPropertyChangedEventHandler"/>
Applies to
Tee yhteistyötä kanssamme GitHubissa
Tämän sisällön lähde on GitHubissa, jossa voit myös luoda ja tarkastella ongelmia ja pull-pyyntöjä. Katso lisätietoja osallistujan oppaasta.