TreeView.SelectedItemChanged TreeView.SelectedItemChanged TreeView.SelectedItemChanged TreeView.SelectedItemChanged Event

定義

SelectedItem が変更されたときに発生します。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) 

次の例のイベント ハンドラーを指定する方法を示しています、SelectedItemChangedイベント。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

注釈

ルーティングされたイベント情報Routed Event Information

識別子フィールドです。Identifier Field SelectedItemChangedEvent
ルーティング方法Routing Strategy バブルBubbling
DelegateDelegate RoutedPropertyChangedEventHandler<T>

XAML 属性の使用方法XAML Attribute Usage

<object SelectedItemChanged="RoutedPropertyChangedEventHandler"/>  

適用対象