如何将两个xml文件绑定到wpf中的单个控件 [英] how to bind two xml files to a single control in wpf
本文介绍了如何将两个xml文件绑定到wpf中的单个控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个XML文件.
Events.xml和Seminar.xml.我正在使用xaml数据提供程序.我的问题是如何将这两个XML文件绑定到单个列表框,我可以通过此代码绑定到单个XML文件.
I am having two XML files.
Events.xml and Seminar.xml. I am using xaml data provider. My question is how to bind these two XML files to a single list box, single XML file I am able to bind through this code.
<Window.Resources>
<XmlDataProvider x:Key="ProductData"
Source="/Product.xml"
XPath="Products/Product" />
</Window.Resources>
并使用-
将其绑定到列表框
And binded it to the list box using -
<ListBox
ItemsSource="{Binding
Source={StaticResource ProductData}}"
DisplayMemberPath="ProductName" />.its working
now i want to to bind two xml files to change the ui continously.i asked m sir he told use collection view source.i searched but iam unable to find out how to do.the place where i lacked is
<XmlDataProvider x:Key="ProductData"
Source="/Product.xml"...///here i have two xml files then how to specify the source
XPath="Products/Product" />...here also
<CollectionViewSource x:Key="collProducts"
Source="{StaticResource ProductData}">
任何人都可以帮助我.
在此先感谢您.
Any one please help me.
Thanks in advance.
推荐答案
您可以轻松地在后面的代码中处理CollectionViewSource来实现所需的功能.在此处查看我的示例 MVVM ListBox分组 [
You''re easier handling the CollectionViewSource in the code behind to achieve what you need. See my example here MVVM ListBox Grouping[^] that has an example of the CollecitonViewSource being manipulated in the code. From this, it should be easy to merge your two xml files into the list.
这篇关于如何将两个xml文件绑定到wpf中的单个控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文