wpf 树视图绑定 [英] wpf treeview binding

查看:29
本文介绍了wpf 树视图绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有关于WPF中的树视图绑定的初学者简单教程?

Is there any simple tutorial for beginners about treeview binding in WPF?

ItemsSource, DataType, ItemTemplate 属性中应该怎么写一个项目列表?

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 代码:

<TreeView Name="treeView1">  
    <TreeView.Resources> <!-- what does it mean? -->
        <HierarchicalDataTemplate DataType="???" ItemsSource="{Binding ???}"></HierarchicalDataTemplate>  
    </TreeView.Resources>  
</TreeView>

推荐答案

为了完全理解如何使用 wpf treeview 和数据绑定,我按顺序浏览了以下教程 -

To Fully understand how to use the wpf treeview with data binding, I went through the following tutorials in order -

  1. 一个非常简单的使用递归的树视图绑定示例

http://testdrivendevelopment.wordpress.com/2008/07/15/databinding-wpf-treeview-using-recursion/

  1. Claus Konrads 数据绑定树视图的简单示例.这是我遇到的最直接的例子,应该能让 wpf 的任何新手跟上进度.

http://blog.clauskonrad.net/2011/04/how-to-make-hierarchical-treeview.html

  1. Mike Hillbergs 教程详细展示了树视图的来龙去脉、它与其他 wpf 控件的比较以及如何绑定数据.

http://blogs.msdn.com/b/mikehillberg/archive/2009/10/30/treeview-and-hierarchicaldatatemplate-step-by-step.aspx

这篇关于wpf 树视图绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆