0

I have an XML file that I want to display in the form of a collapsible table in WPF.

<?xml version="1.0" encoding="utf-8"?>
<TestSet>
  <Test TestName="Create Contact" Result="Passed">
    <Step>
      <StepNumber>1</StepNumber>
      <StepName>Start Pivotal</StepName>
      <Result>Passed</Result>
      <Comment>Attached to existing instance of Pivotal</Comment>
    </Step>
    <Step>
      <StepNumber>2</StepNumber>
      <StepName>Click on element</StepName>
      <Result>Passed</Result>
      <Comment>Clicked on Pivotal element [contacts tab]</Comment>
    </Step>
  </Test>
  <Test TestName="Create Contact" Result="Passed">
    <Step>
      <StepNumber>1</StepNumber>
      <StepName>Start Pivotal</StepName>
      <Result>Passed</Result>
      <Comment>Attached to existing instance of Pivotal</Comment>
    </Step>
    <Step>
      <StepNumber>2</StepNumber>
      <StepName>Click on element</StepName>
      <Result>Passed</Result>
      <Comment>Clicked on Pivotal element [contacts tab]</Comment>
    </Step>
  </Test>
</TestSet>

When I read this into a DataSet I get two tables, Table[0] which contains 2 Tests, and Table1 with 4 Steps and both tables are linked with a relationship of "TestId" that is generated by the data reader.

What I need is to display a table with the contents of Table[0] that has expandable [+] indicators, and when expanded, the relational values from Table1 is displayed underneath the row.

I have tried all sorts of solutions with DataGrid's and CollectionViewSource but haven't been able to get this to work. Can anyone help me piece this together? Have I taken the wrong approach by creating a DataSet from the XML first?

Note that the columns of each table are different (except the keys). Here is an example of what it might look like: enter image description here

Scotty
  • 455
  • 7
  • 15
  • Maybe something like this: [Binding a TreeView to a DataSet](https://joshsmithonwpf.wordpress.com/2007/05/05/binding-a-treeview-to-a-dataset/). – dbc May 05 '15 at 04:53
  • It needs to be in a tabular format. I don't think TreeView can do that – Scotty May 05 '15 at 05:04
  • Maybe something like this: http://stackoverflow.com/questions/5502513/creating-a-wpf-hybrid-control-treeview-datagrid-datatreegrid or this: http://stackoverflow.com/questions/22357832/wpf-how-to-put-a-tree-view-inside-the-datagrid – dbc May 05 '15 at 05:13
  • http://csharp.net-informations.com/xml/xml-to-database.htm Try dis may it's work – Dhru 'soni May 05 '15 at 05:21
  • Try a treeview with columns : http://www.codeproject.com/Articles/23746/TreeView-with-Columns – jdweng May 05 '15 at 05:37
  • Thanks everyone for the suggestions. The solutions suggested all result in a single table with the same columns, but my tables are columns do not align up (and I dont want to have a heap of blank columns just sitting around). I have added an image of what I expected the solution to look like, can anyone suggest anything for that? – Scotty May 05 '15 at 05:47

0 Answers0