0
我有两个相似的子树分级数据结构:我可以参数化wpf分层数据模板上的数据源吗?
Iteration:
string Name
string Image
ObservableCollection<Iteration> SubIterations
ObservableCollection<Iteration> BacklogIterations
我想现在树的两个略有不同的观点,使用两个树视图。
- 树1:显示子迭代
- Tree2:显示BacklogIterations
元素应显示的一样,但是孩子的项目需要使用不同的属性被拾起。
即我想参数化的ItemsSource在HierarchicalDataTemplate:
<HierarchicalDataTemplate x:Key="IterationItem"
ItemsSource="{Binding SubIterations}"
>
<StackPanel Orientation="Horizontal">
<Image Width="32" Height="32"
Margin="3,0" Source="{Binding Picture}" />
<TextBlock Text="{Binding Name}" />
</StackPanel>
</HierarchicalDataTemplate>
<TreeView ItemsSource="{Binding RootSprintIteration}">
</TreeView>
<TreeView ItemsSource="{Binding RootBacklogIteration}">
</TreeView>
我怎样才能获得HierarchicalDataTemplate在第二树使用不同的ItemsSource? 我不想复制整个HierarchicalDataTemplate定义只是为了更改ItemsSource。