所以这就是事情,我花了差不多一个星期的时间试图让这件事情发挥作用,而我却得不到它。如果我静态编码嵌套的扩展器,例如
<expander>
<expander>
<expander/>
</expander>
<expander>
一切都有效,但当我创造出相同的&#39;相同的&#39;嵌套控件的东西顶部扩展器工作正常,但第二个扩展器随之扩展,如果我尝试单击嵌套的那个,它会翻转,我看到了:
A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll
Additional information: Logical tree depth exceeded while traversing the tree. This could indicate a cycle in the tree.
单词无法描述XAML引起的挫败感,这里是导致整个shabang的代码片段:
<Style TargetType="{x:Type cpg:Category}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type cpg:Category}">
<Border>
<Expander Header="{Binding DisplayName, RelativeSource={RelativeSource TemplatedParent}}">
<ItemsControl ItemsSource="{Binding Properties, RelativeSource={RelativeSource TemplatedParent}}"></ItemsControl>
</Expander>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
有人曾经解决过这个问题吗?
哦,我应该补充一点,ItemsControl包含相同类型的其他对象,因此它会嵌套。我认为它可能是由嵌套绑定引起的,但在尝试了所有不同类型的绑定后,我仍然处于亏损状态。
更新:这个问题不仅限于扩展器,如果我使用任何其他容器也会发生同样的事情:/
update2:只有当孩子属于同一个班级时才会发生这种情况。我复制粘贴模板并将其用于另一个类,它没关系:/