WPF TreeView绑定字典集合
1 <TreeView Name="Tree" HorizontalAlignment="Left" Height="269" Width="292" > 2 3 <TreeView.ItemTemplate> 4 <HierarchicalDataTemplate ItemsSource="{Binding Value}"> 5 <StackPanel> 6 <TextBlock Text="{Binding Key.DepartmentName}" Background="Red" /> 7 </StackPanel> 8 9 <HierarchicalDataTemplate.ItemTemplate> 10 <HierarchicalDataTemplate> 11 <TextBlock Text="{Binding Path=ParsonName}"/> 12 </HierarchicalDataTemplate> 13 </HierarchicalDataTemplate.ItemTemplate> 14 </HierarchicalDataTemplate> 15 </TreeView.ItemTemplate>
Key为实体类,Valuey也是实体类,ParsonName是Value集合的实体类字段