如何将 XPathNodeIterator 与 WPF DataGrid 结合使用?
如何将 XPathNodeIterator 与 WPF DataGrid 结合使用?这是我想做的:
Dim xpd As New Xml.XPath.XPathDocument("filename.txt")
Dim xpn As Xml.XPath.XPathNavigator = xpd.CreateNavigator
DataGrid1.DataContext = xpn.Select("/node1/node2")
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")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用哪个数据网格?最有可能的是,您希望分配 DataGrid1.ItemsSource = xpn.Select("/node1/node2")。需要明确的是,这会将网格绑定到 xpn.Select 结果的 IEnumerable 中的任何对象。如果这就足够了,那就太好了。否则,您可能需要考虑将 xpn.Select(...) 的结果投影到通过 LINQ 有意义的对象中。
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.