listbox绑定XML文件(wpf)

五位数 2011-01-06 02:51:26
单项的绑定listbox是可以的代码如下
MainWindow.xaml文件
<Window x:Class="ListBoxBing.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<XmlDataProvider x:Key="MyTask" Source="Task.xml" XPath="/root"/>

</Window.Resources>
<Grid>
<ListBox Height="149" HorizontalAlignment="Left" Margin="114,66,0,0" Name="listBox1" VerticalAlignment="Top" Width="205" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource MyTask},Mode=OneWay,
XPath=Task/@name}"
/>
<Button Content="Button" Height="46" HorizontalAlignment="Left" Margin="384,51,0,0" Name="button1" VerticalAlignment="Top" Width="76" Click="button1_Click" />
</Grid>
</Window>

Task.xml文件结构如下

<?xml version="1.0" encoding="utf-8"?>
<root>
<Task Nid="1" name="111"/>
<Task Nid="2" name="222"/>
<Task Nid="3" name="333"/>
<root>

现在我修改task.xml的内容。界面并没有变化

不知道是什么问题,希望知道的哥们指点一下。谢谢
...全文
145 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
五位数 2011-01-06
  • 打赏
  • 举报
回复
等待,正确答案。。。。。
五位数 2011-01-06
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wuyq11 的回复:]
http://greenlandy.blogbus.com/logs/14664333.html
[/Quote]

这个文章似乎不是我需要的哦。
五位数 2011-01-06
  • 打赏
  • 举报
回复
刷新的速度好快。。。。。。。。

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧