数据绑定XML->树视图 [英] Databinding XML -> Treeview

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

问题描述

你好

我想通过将XML文档的结构绑定到Treeview控件来使其可视化.我已经尝试了几件事:

I want to visualize the structure of a XML document by binding it to a Treeview Control. I have tried several things:

版本1

XDocument doc = XDocument.Load(openFileDialog1.FileName);
this.treeView1.DataContext = doc.Root.Elements();

版本2

XmlDocument doc = new XmlDocument();
doc.Load(openFileDialog1.FileName);
Binding bnd = new Binding();
bnd.Source = doc.InnerXml;
this.treeView1.SetBinding(TreeView.ItemsSourceProperty, bnd);

两个都不起作用.
感谢您的帮助

Both didn't work.
Thx for your help

推荐答案

Jogreface,

Hi Jogreface,

请检查以下内容:

http://stackoverflow.com/questions /188001/two-way-binding-of-xml-data-to-the-wpf-treeview


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

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