...
<Window.Resources>
<!--TODO: Add an XmlDataProvider here-->
</Window.Resources>
...
You can bind controls to an XML file by using the XmlDataProvider.
This topic does not cover binding the XmlDataProvider to any specific control; however, you will need to use the XmlDataProvider created in this topic for control specific tasks. For information on binding a control to the XmlDataProvider you created in this topic, use the links provided at the end of this topic.
This topic will show you how to create an XmlDataProvider object in Extensible Application Markup Language (XAML). The XAML for declaring the XmlDataProvider is written generically enough that it is control-independent.
The XML file used in this topic is called Orders.xml, and is available for you to download. The example XAML code assumes the XML file exists in a folder called "Data" in your project.
Create a Microsoft® Windows® Presentation Foundation Window project.
Create a Resource section in your Window or Page.
In XAML:
...
<Window.Resources>
<!--TODO: Add an XmlDataProvider here-->
</Window.Resources>
...
Add an XmlDataProvider to the Resources section.
Key - Set the Key property to OrderData. You can use this key to reference the data provider later.
Source - Set the Source property to Data/Orders.xml.
In XAML:
...
<XmlDataProvider x:Key="OrderData" Source="Data/Orders.xml" />
...
Running your application at this time will just display an empty Window. You will have to add a control to the Window and bind the XmlDataProvider that you created in this topic to the control in order to see the results. Use the links provided below to bind the XmlDataProvider to a specific control.