C# TreeView没有';你不打算参加后扩展活动吗?

C# TreeView没有';你不打算参加后扩展活动吗?,c#,.net,wpf,xaml,treeview,C#,.net,Wpf,Xaml,Treeview,我尝试使用一个树视图来浏览潜在的循环层次结构数据。 这意味着我不能一次加载所有的树,因为那时可能会有无限的循环 我想对TreeView.AfterCollapse事件做出反应 然而,我的控制似乎没有这个事件。如果尝试添加AfterExpand属性,则会收到以下错误消息: error MC3072: The property 'AfterExpand' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006

我尝试使用一个树视图来浏览潜在的循环层次结构数据。 这意味着我不能一次加载所有的树,因为那时可能会有无限的循环

我想对TreeView.AfterCollapse事件做出反应

然而,我的控制似乎没有这个事件。如果尝试添加AfterExpand属性,则会收到以下错误消息:

 error MC3072: The property 'AfterExpand' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 23 Position 21.
我做错了什么?调用错误的命名空间? 代码如下:

<Window x:Class="MyApp.Edit.EditView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyApp.Edit"
    Title="{Binding WindowTitle,UpdateSourceTrigger=PropertyChanged}" MinHeight="350" MinWidth="350">

    <Window.Resources>
        <HierarchicalDataTemplate x:Key="sectionTemplate"
        ItemsSource="{Binding ChildSections}"
        DataType="{x:Type local:Section}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Label, UpdateSourceTrigger=PropertyChanged}" />
                <TextBlock Text=" - " />
                <TextBlock Text="{Binding Description}" FontStyle="Italic" Foreground="#777" />
            </StackPanel>
        </HierarchicalDataTemplate>
    </Window.Resources>

    <StackPanel>

    <TreeView ItemsSource="{Binding Sections}"
                SelectedItemChanged="TreeView_SelectedItemChanged"
                ItemTemplate="{StaticResource sectionTemplate}"
                MinHeight="150"
                MinWidth="300"
                Name="treeView"
                AfterExpand="MyEventHandler"
        </TreeView>

        <TextBox Text="{Binding Label, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                 Margin="0 10 0 0"/>

        <TextBox Text="{Binding Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" 
                 Margin="0 10 0 0"/>

        <StackPanel Orientation="Horizontal">
            <Button Content="Add Child" Click="Button_Click_AddChild" />
        </StackPanel>
    </StackPanel>
</Window>


这是一个Windows窗体树视图事件,它不属于WPF
TreeView
,在WPF中,您可以使用
TreeViewItems
,而不是
TreeView
本身


但是,您可以按原样订阅
树视图上的事件。

我认为它在wpf中不可用。