Start with having an XML Datasource for the purpose of this example we’ll use the following and it will be stored in a separate XML File titled SalesPeople.xml:
Next, we need to set this data up for use inside our application. In the case of this sample, I’ve set our XamDataGrid into a GridPanel and set the DataContext of that grid to point at our XML Data. We’ll set the source property of the XMLDataProvider equal to the file location in this case in a folder titled Data. Then we’ll set the XPath to point to our SalesPersons. This will look something like this:
Next, using simple WPF Binding, we can bind the xml file to the XamDataGrid:
Lastly, we may want to do something like enable Summaries on the xamDataGrid and will notice that everything is being picked up as a string. To get around this we can format our data as the appropriate type by adding the Fields and associating the appropriate types to those fields. Note: We can also format the field’s labels to achieve something like “First Name” rather than “FirstName.”
After this our data is all set up and ready to go. We have successfully bound our grid to an XML File.