我有一个带有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>
如何添加扩展事件? 感谢
答案 0 :(得分:1)
你可以这样做:
在XAML中:
&lt; TreeView ... TreeViewItem.Expanded =“TreeViewItem_Expanded”/&gt;
代码背后:
public void TreeViewItem_Expanded(object s,RoutedEventArgs e){...}