上个月做好的,电脑给盗了,没及时存在网盘,也及时发到随笔,于是乎悲哉!搞了一个上午终于绑定好了,有时候就是这么眼瞎,Path和XPath全瞎了,摸滚了一个上午,赶紧的随笔跟上先。
<ListView Margin="0,0,284,0" Name="listview">
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource ColumnHeaderStyle}">
<GridViewColumn Header="id" Width="" DisplayMemberBinding="{Binding XPath=@id}" />
<GridViewColumn Header="X" Width="" DisplayMemberBinding="{Binding XPath=X}" />
<GridViewColumn Header="Y" Width="" DisplayMemberBinding="{Binding XPath=Y}" />
<GridViewColumn Header="Z" Width="" DisplayMemberBinding="{Binding XPath=Z}" />
</GridView>
</ListView.View>
</ListView>
拉了个Button,乱七八糟的不管了,跟上先
private void button2_Click(object sender, RoutedEventArgs e)
{
string ExePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\MyInfo.xml"; // 1.创建一个XmlDocument类的对象
XmlDocument doc = new XmlDocument();
// 2.把你想要读取的xml文档加载进来
doc.Load(ExePath);
// 3.读取你指定的节点
XmlNode xn = doc.SelectSingleNode("Root");
XmlNodeList lis = xn.ChildNodes;
// 4.取节点中的值
String str = lis[].InnerText;
listview.DataContext = xn;
listview.SetBinding(ListView.ItemsSourceProperty, new Binding());
//listview.Items.Refresh();
}
效果图