本文介绍了如何将可观察集合绑定到Wpf树视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将可观察集合绑定到Wpf树视图?给我一个很好的例子

How to bind observable collection to Wpf Tree view? give me good example

推荐答案

<treeview itemssource="{x:Static local:Window1.AnimalCategories}">

   <treeview.itemtemplate>
     <hierarchicaldatatemplate itemssource="{Binding Path=Animals}">

       <textblock fontweight="Bold" text="{Binding Path=Category}" />

       <hierarchicaldatatemplate.itemtemplate>

         <datatemplate>

           <textblock text="{Binding Path=Name}" />

         </datatemplate>
       </hierarchicaldatatemplate.itemtemplate>

     </hierarchicaldatatemplate>

   </treeview.itemtemplate>

 </treeview>





欲了解更多信息,请查看此链接



[]



谢谢

Sujeet



for more information please check this link

WPF Treeview: Styling and Template Binding using MVVM[^]

Thanks
Sujeet



这篇关于如何将可观察集合绑定到Wpf树视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 00:25