A "grid in grid"

Nov 23, 2008 at 6:59 PM
Hi!

What is the prefered approach for adding another grid in the grid, tied to each row.
My best guess is to add it in the RowDetailsTemplate, would that be a good place for building this feature?

/Cake
Nov 24, 2008 at 8:51 AM
Hi,

 Your guess is right, at least this is how I implemented it. Here is an example:

 I've declared a datatemplate

<DataTemplate x:Key="AssociationTemplate" DataType="{x:Type commonInterfaces:IRelation}">
                <ListBox ItemsSource="{Binding Path=RelationEntities}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <toolkit:DataGrid HeadersVisibility="Column" AutoGenerateColumns="True"
                                              CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="True" IsReadOnly="True"
                                              Grid.Row="2"
                                              AutoGeneratingColumns="dataGrid_AutoGeneratingColumns"
                                              HorizontalGridLinesBrush="AliceBlue" 
                                              GridLinesVisibility="Horizontal" Background="Transparent"
                                              ClipboardCopyMode="None" 
                                              ItemContainerStyleSelector="{StaticResource ListViewItemStyleSelector}"
                                              ItemsSource="{Binding}"/>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DataTemplate>

And here is how I use the datatemplate
<toolkit:DataGrid Name="dataGrid" RowDetailsTemplate="AssociationTemplate" />

work like a charm.

Regards,
Calin,