How can I use an XPathNodeIterator with WPF DataGrid?

149 Views Asked by At

How can I use an XPathNodeIterator with a WPF DataGrid? Here's what I'd like to do:

        Dim xpd As New Xml.XPath.XPathDocument("filename.txt")
        Dim xpn As Xml.XPath.XPathNavigator = xpd.CreateNavigator
        DataGrid1.DataContext = xpn.Select("/node1/node2")
1

There are 1 best solutions below

0
On

Which data grid are you using? Most likely, you want to assign DataGrid1.ItemsSource = xpn.Select("/node1/node2"). To be clear, this will bind the grid to whatever objects are in the xpn.Select result's IEnumerable. If that is enough, great. Otherwise, you might want to consider projecting the result of xpn.Select(...) into objects that make sense via LINQ.