How can I use an开发者_JAVA技巧 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")
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.
精彩评论