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集合的实体类字段

posted @ 2014-08-05 16:21  b̶i̶n̶g̶.̶  阅读(507)  评论(0编辑  收藏  举报