将事件扩展到 TreeView wpf

expanded event to TreeView wpf

我有一个带有 HierarchicalDataTemplate 的 treeView,我想添加扩展事件

<TreeView Name="files" Margin="0,0,569,108" Grid.Row="1" ItemsSource="{Binding s1}">
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Members}">
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Name}" />                              
                                </StackPanel>
                                <HierarchicalDataTemplate.ItemTemplate>
                                    <DataTemplate>
                                        <CheckBox Name="CheckBox111" Checked="FileCheckBox_Checked" Unchecked="FileCheckBox_Unchecked" IsChecked="{Binding C}"/>
                                    </DataTemplate>
                                </HierarchicalDataTemplate.ItemTemplate>
                            </HierarchicalDataTemplate>

                        </TreeView.ItemTemplate>
                    </TreeView>

如何添加展开的事件? 谢谢

你可以做到:

在XAML中:

<树视图 ... TreeViewItem.Expanded="TreeViewItem_Expanded" />

隐藏代码:

public void TreeViewItem_Expanded(object s, RoutedEventArgs e) {...}