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。