Is there a means for binding the grid to an arbitrary XML source? In my application I view a list of XML tags in a treeview. I was considering replacing this with a xamDataGrid bound to the XML with the intent of showing an expandable tree of tags with the content of the tag shown in a second column and, possibly, details of attributes in further columns. The key problem is that I cannot predict the contents of the XML document.
Is this possible?
This is rather strange.
I can see in the group by area that the Grid knows of #documents -> Jobs -> Owner -> #text
How can I show the information used by the group by header in the grid?
Unfortunately I do not have any control over the XML that comes in. It's provided by users and can contain any content including any attributes. I just want to lay it out in a manner that's easy to read. I think that the xamDataGrid is possibly not going to be a solution for me in this case.
The XamDataGrid does not show these (the SubTask and the Duration attribute) because of the inconsistencies in the xml you are creating. You have duration only on one of the tasks and subtask again only one just one. This will work properly if every Task has a Duration attribute and SubTask sub element.
You should also put an xml namespace in the parent tag. I am pasting the working xml for that:
<Jobs xmlns="">
<Job>
<Owner>Ted</Owner>
<Tasks>
<Task id="Task1" Duration="0">
<SubTasks>
<SubTask>SubTask 1</SubTask>
</SubTasks>
</Task>
<Task id="Task2" Duration="0">
<Task id="Task3" Duration="5">
</Tasks>
</Job>
</Jobs>
Hope this helps.
Here's some sample code. This assumes a xamDataGrid with the name "MyGrid" exists. In this example, the top level node includes the owner (where I would like it to show "Job" but none of the tag names appears anywhere). The Duration attribute and the Subtasks aren't shown.
XmlDocument xml = new XmlDocument(); xml.LoadXml(
@"
<Task id=""Task1"">Task One</Task>
<Task id=""Task2"" Duration=""5"">Task Two</Task>
<Task id=""Task3"">Task Three
<SubTask>Subtask 1</SubTask>
"
MyGrid.DataSource = xml;
Can you provide a sample structure of such xml document that illustrates the problem?