1
对不起,我刚开始使用wpf编程。我似乎无法弄清楚为什么下面的xaml显示“System.Xml.XmlElement”,而不是实际的XML节点内容。每当我运行它时,它会在列表框中显示5次。不知道我要去哪里错...XmlDataProvider转换器问题
<Window x:Class="TestBinding.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<XmlDataProvider x:Key="myXmlSource" XPath="/root">
<x:XData>
<root xmlns="">
<name>Steve</name>
<name>Arthur</name>
<name>Sidney</name>
<name>Billy</name>
<name>Steven</name>
</root>
</x:XData>
</XmlDataProvider>
<DataTemplate x:Key="shmooga">
<TextBlock Text="{Binding}"/>
</DataTemplate>
</Window.Resources>
<Grid>
<ListBox ItemTemplate="{StaticResource shmooga}"
ItemsSource="{Binding Source={StaticResource myXmlSource}, XPath=name}">
</ListBox>
</Grid>
</Window>
任何帮助将非常感激。谢谢!
这是伟大的!谢谢!我真的很难过这个。 – Andrew 2010-04-16 23:46:28