Binding to an External XML Source
The previous example shows how you can bind an XML data island to the various controls in your WPF application. One problem with using an XML data island within the application is that any changes to the XML data will require the application to be modified/compiled. A better approach would be to store the XML data in an external file and then reference it within the application. For example, you could save the XML data in a file called RSS.xml and then reference it within the application as:
<XmlDataSource x:Key="RSSData"
Source="RSS.xml"
XPath="/rss/channel"
/>
Dynamically Loading the XML Source
While you can reference an external XML file, a better approach would be to dynamically load the XML document from a URL. In this case, you would modify your <XmlDataSource> element as:
<XmlDataSource x:Key="RSSData"
Source="http://services.devx.com/outgoing/devxfeed.xml"
XPath="/rss/channel"
/>
Try using the following URLs and see that the application loads a different set of RSS items each time:
Going Further
In this article, you have seen how data-binding works in WPF. For those who want to take the sample application further, consider modifying the application to allow users to select from a list of URLs (instead of manually modifying the source of the XML document). Otherwise, I encourage you to download the sample code and see for yourself how data binding works in WPF.