共用方式為


TreeViewItem.Expanded 事件

定義

IsExpanded 屬性從 false 變更為 true 時發生。

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

事件類型

範例

下列範例示範如何將 事件的事件處理常式 Expanded 指派給 , TreeViewItem 以及如何在程式碼後置中定義事件處理常式。

<TreeViewItem Header="Employee1"
              Name="Employee1Data" 
              IsExpanded="True" 
              Collapsed="OnCollapsed" 
              Expanded="OnExpanded">
  <TreeViewItem Header="Work Days" 
                Name="EmployeeWorkDays"
                IsSelected="True">
    <TreeViewItem Header="Tuesday" />
    <TreeViewItem Header="Friday"/>
  </TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="Employee2" 
              Name="Employee2Data">
  <TreeViewItem Header="Work Days" 
                Name="emp2WorkDays" 
                Selected="GetSchedule"
                Unselected="SetSchedule">
    <TreeViewItem Header="Monday" />
    <TreeViewItem Header="Wednesday"/>
  </TreeViewItem>
</TreeViewItem>
private void OnExpanded(object sender, RoutedEventArgs e)
{
    //Perform actions when the TreeViewItem is expanded
}
Private Sub OnExpanded(ByVal sender As Object, ByVal e As RoutedEventArgs)
    'Perform actions when the TreeViewItem is expanded
End Sub

備註

展開 TreeViewItem 時,就會發生此事件,使其子專案可見。

路由事件資訊

識別碼欄位 ExpandedEvent
路由策略 鼓 泡
代理人 RoutedEventHandler

適用於

另請參閱