I want to show XmlData within a ListView. The XmlDataProvider is filled correctly but the Listview only shows the first line. What do I have to change to show all lines inside the 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>
In code behind:
private void RefreshList(XmlDocument doc)
{
XmlDataProvider provider = (XmlDataProvider)FindResource("xmlData");
provider.Document = doc;
provider.Refresh();
}
Ok so I solved it this way:
See source below.
<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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.