I have a xml like this:
<root>
<project name="p1">
<row field1="31" field2="3" Name="Joe"/>
<row field1="39" field2="3" Name="Joey"/>
<row field1="37" field2="3" Name="Joei"/>
</project>
<project name="p2">
<row field1="31" field2="3" Name="Joe"/>
<row field1="39" field2="3" Name="Joey"/>
</project>
</root>
Now the listbox displays the projects. When a project is selected in listbox, a grid has to display the rows. Is it possible to do this in Xaml? Or should i do it in the code as part of listbox’s selectionChanged Event?
Yes. Just name your ListBox, bind the DataGrid’s DataContext property to the ListBox’s SelectedItem property, then set the ItemsSource of the DataGrid to the corresponding xml node.
See the code below. It uses a ListView, though, instead of a DataGrid.