我想在ListView中显示XmlData。 XmlDataProvider已正确填充,但Listview仅显示第一行。我需要更改什么来显示XmlDocument中的所有行?
<Window.Resources>
<XmlDataProvider x:Key="xmlData"/>
</Window.Resources>
<DockPanel>
<ListView Padding="4">
<ListView.ItemsSource>
<Binding Source="{StaticResource xmlData}" XPath="*"/>
</ListView.ItemsSource>
<ListView.View>
<GridView >
<GridViewColumn Header="Info" Width="256" DisplayMemberBinding="{Binding XPath=Message}"/>
</GridView>
</ListView.View>
</ListView>
</DockPanel>
在代码背后:
private void RefreshList(XmlDocument doc)
{
XmlDataProvider provider = (XmlDataProvider)FindResource("xmlData");
provider.Document = doc;
provider.Refresh();
}
答案 0 :(得分:0)
好的,所以我这样解决了:
见下文摘要。
<Window.Resources>
<XmlDataProvider x:Key="xmlData" XPath="//Prototype"/>
</Window.Resources>
<DockPanel>
<ListView>
<ListView.ItemsSource>
<Binding Source="{StaticResource xmlData}" XPath="Message"/>
</ListView.ItemsSource>
<ListView.View>
<GridView >
<GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Path=InnerText}"/>
</GridView>
</ListView.View>
</ListView>
</DockPanel>