TreeViewItem.Selected 事件

定义

IsSelectedTreeViewItem 属性从 false 更改为 true 时发生。

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

事件类型

示例

以下示例演示如何将 事件的事件处理程序 Selected 分配给 TreeViewItem,以及如何定义事件处理程序。

<TreeViewItem Header="Employee2" 
              Name="Employee2Data">
  <TreeViewItem Header="Work Days" 
                Name="emp2WorkDays" 
                Selected="GetSchedule"
                Unselected="SetSchedule">
    <TreeViewItem Header="Monday" />
    <TreeViewItem Header="Wednesday"/>
  </TreeViewItem>
private void GetSchedule(object sender, RoutedEventArgs e)
{
    //Perform actions when a TreeViewItem
    //controls is selected
}
Private Sub GetSchedule(ByVal sender As Object, ByVal e As RoutedEventArgs)
    'Perform actions when a TreeViewItem
    'controls is selected
End Sub

注解

TreeViewItem 成为 控件中的TreeView选定 TreeViewItem 时,将发生该事件。 此事件与控件的 SelectedItemChanged 属性TreeView发生更改SelectedItem时发生的事件相关。

路由事件信息

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

适用于

另请参阅