我正在尝试(成功有限)创建一个包含动态和静态数据混合的TreeView。
您将在下面找到我目前最好的尝试,但是因为我正在嵌套TreeViews,所以有一个副作用,其中可以在父TreeView中选择多个项目。当我尝试嵌套TreeViewItems时,结果不是正面的,即只显示ItemTemplate中的父级TreeViewItem,并且创建了它的子节点空间,但没有输出任何内容。
我真的很想知道如何实现我的目标,而无需在我绑定到TreeView的集合中指定整个菜单。
谢谢
<telerik:RadTreeView Width="225" HorizontalAlignment="Left" Background="Transparent" FontWeight="SemiBold">
<telerik:RadTreeViewItem Header="Customer" Command="{Binding OpenCustomerCommand}"/>
<telerik:RadTreeViewItem Header="Sites" Command="{Binding OpenSiteBrowserCommand}" ItemsSource="{Binding Sites}">
<telerik:RadTreeViewItem.ItemTemplate>
<DataTemplate>
<telerik:RadTreeView>
<telerik:RadTreeViewItem Header="{Binding Key}"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenSiteCommand}"
CommandParameter="{Binding Value}">
<telerik:RadTreeViewItem Header="Material Profiles"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenMaterialProfileBrowserCommand}"
CommandParameter="{Binding Value}"/>
<telerik:RadTreeViewItem Header="Prices"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenPriceBrowserCommand}"
CommandParameter="{Binding Value}"/>
<telerik:RadTreeViewItem Header="Orders"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenOrderBrowserCommand}"
CommandParameter="{Binding Value}"/>
<telerik:RadTreeViewItem Header="Activity">
<telerik:RadTreeViewItem Header="Collection"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenActivityCollectionsBrowserCommand}"
CommandParameter="{Binding Value}"/>
<telerik:RadTreeViewItem Header="Call Outs"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenActivityCallOutBrowserCommand}"
CommandParameter="{Binding Value}"/>
<telerik:RadTreeViewItem Header="Gate"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenActivityGateBrowserCommand}"
CommandParameter="{Binding Value}"/>
<telerik:RadTreeViewItem Header="One Off Charges"
Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=view:WindowViewBase},
Path=DataContext.OpenActivityOneOffChargeBrowserCommand}"
CommandParameter="{Binding Value}"/>
</telerik:RadTreeViewItem>
</telerik:RadTreeViewItem>
</telerik:RadTreeView>
</DataTemplate>
</telerik:RadTreeViewItem.ItemTemplate>
</telerik:RadTreeViewItem>
答案 0 :(得分:0)
Telerik已确认使用他们的RadTreeView控件无法实现这一点,他们已将其添加到他们的TODO列表中。
感谢您的评论。