wpf treeview绑定 [英] wpf treeview binding
问题描述
我们应该在ItemsSource,DataType,ItemTemplate属性中写什么,如果有
一个项目列表?
IList< string> items = new List< string>();
items.Add(item1);
items.Add(item2);
items.Add(item3);
XAML代码:
< TreeView Name =treeView1>
< TreeView.Resources>这是什么意思? - >
< HierarchicalDataTemplate DataType =??? ItemsSource ={Binding ???}>< / HierarchicalDataTemplate>
< /TreeView.Resources>
< / TreeView>
要充分了解如何使用wpf treeview与数据绑定,我按顺序浏览了以下教程 -
1)使用递归的一个非常简单的树视图绑定示例
http://testdrivendevelopment.wordpress.com/2008/07/15 / databinding-wpf-treeview-using-recursion /
2)Claus Konrads使用树视图进行数据绑定的简单示例。这是我遇到的最直截了当的例子,应该能够让任何新手加入wpf。
http://blog.clauskonrad.net/2011/04/how-to-make-hierarchical-treeview.html
3)Mike Hillbergs教程详细介绍了treeview的内容,它与其他wpf控件的对比以及如何绑定数据。
Is there any simple tutorial for beginners about treeview binding in WPF?
What should we write in ItemsSource, DataType, ItemTemplate attributes if there's one List of items?
IList<string> items = new List<string>();
items.Add("item1");
items.Add("item2");
items.Add("item3");
XAML code:
<TreeView Name="treeView1">
<TreeView.Resources> <!-- what does it mean? -->
<HierarchicalDataTemplate DataType="???" ItemsSource="{Binding ???}"></HierarchicalDataTemplate>
</TreeView.Resources>
</TreeView>
To Fully understand how to use the wpf treeview with data binding, I went through the following tutorials in order -
1) A very simple example of treeview binding using recursion
http://testdrivendevelopment.wordpress.com/2008/07/15/databinding-wpf-treeview-using-recursion/
2) Claus Konrads simple example of data binding with the treeview. It's the most straightforward example I have come across and should get any newcomers to wpf up to speed.
http://blog.clauskonrad.net/2011/04/how-to-make-hierarchical-treeview.html
3) Mike Hillbergs tutorial shows, in detail, the ins and outs of the treeview, how it compares to other wpf controls, and how to bind data.
这篇关于wpf treeview绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!