Can you use DataGrid in HeirarchicalDataTemplate?

Dec 14, 2008 at 2:55 PM
Edited Dec 14, 2008 at 3:02 PM
Hi,
I have a treeview of Customers that contains Orders (List) which contains OrderDetails (List). I can display these OrdersDetails fine if I specify a TextBlock for each field. What I would like to do is to put the OrdersDetails data in a DataGrid so you can sort or change the order of the OrderDetails fields. I can't seem to figure out how to get this to work and am wondering if anyone has done anything like this?

 

<Grid.Resources>

 

 

<!-- ORDER DETAIL TEMPLATE --> 
<DataTemplate x:Key="OrderDetailTemplate"> 
<TextBlock>

 

 

 

 

<Run>Product:</Run>

 

 

 

 

<TextBlock Text="{Binding Path=Product}" />    I would like to put this information in a datagrid................

 

 

 

 

 

<Run>(</Run>

 

 

 

 

<TextBlock Text="{Binding Path=Quantity}" />    I would like to put this information in a datagrid................

 

 

 

 

 

<Run>)</Run>

 

 

 

 

 

 

</TextBlock>

 

 

 

 

 

 

</DataTemplate 

 

 

 

 

<!-- ORDER TEMPLATE -->

 

<HierarchicalDataTemplate x:Key="OrderTemplate"  ItemsSource="{Binding Path=OrderDetails}"  ItemTemplate="{StaticResource OrderDetailTemplate}"  >

 

 

 

 

 

 

<TextBlock Text="{Binding Path=Desc}" />

 

 

 

 

 

 

</HierarchicalDataTemplate>

 

 

 

 

 

 

<!-- CUSTOMER TEMPLATE -->

 

 

 

 

 

 

<HierarchicalDataTemplate x:Key="CustomerTemplate"  ItemsSource="{Binding Path=Orders}"  ItemTemplate="{StaticResource OrderTemplate}"  >

 

 

 

 

 

 

<TextBlock Text="{Binding Path=Name}" />

 

 

 

 

 

 

</HierarchicalDataTemplate>

 

 

 

 

 

 

</Grid.Resources>

 

 

 

 

 

 

<TreeView  ItemsSource="{Binding Path=.}"  ItemTemplate="{StaticResource CustomerTemplate}"  />

 

 

 

 

 

 

</Grid>

thanks in advance for any suggestions!
Bill