views:

222

answers:

1

Hey Guys, I want to use a Datagrid as conten of another Datagrid's RowDetailsTemplate. It works nerarly perfect, but there is the problem, that the child Datagrid ColumnDefinition seems to have no effect.

Here is my Code:

<toolkit:DataGrid VerticalAlignment="Top" HorizontalAlignment="Stretch"
                            AutoGenerateColumns="False"  ItemsSource="{Binding Hauptgruppen}" 
                            IsReadOnly="False"  x:Name="HauptgruppenDataGrid"
                            CanUserAddRows="False"
                            SelectionUnit="FullRow"
                            gridtools:DataGridStyle.SelectAllButtonTemplate="{DynamicResource CisSelectAllButtonTemplate}"
                            SelectedValuePath="."
                            CanUserResizeColumns="True" 
                            >

        <toolkit:DataGrid.RowDetailsTemplate>

            <DataTemplate>
                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF4E5790">
                    <toolkit:DataGrid VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="50,5,5,5"
                                  ItemsSource="{Binding ElementName=HauptgruppenDataGrid, Path=SelectedValue.BerechtigteUntergruppen}"
                                  x:Name="UntergruppenDataGrid" IsReadOnly="False"
                                  CanUserAddRows="False"
                                  SelectionUnit="FullRow"
                                  gridtools:DataGridStyle.SelectAllButtonTemplate="{DynamicResource CisSelectAllButtonTemplate}"
                                  SelectedValuePath="."
                                  CanUserResizeColumns="True" 
                                  >
                        <toolkit:DataGrid.RowDetailsTemplate>

                                <DataTemplate>
                                    <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF4E5790">
                                        <toolkit:DataGrid VerticalAlignment="Top" HorizontalAlignment="Stretch" Margin="50,5,5,5"
                                          ItemsSource="{Binding ElementName=UntergruppenDataGrid, Path=SelectedValue.BerechtigteRisiken}"
                                          x:Name="RisikenDataGrid" IsReadOnly="False"
                                          CanUserAddRows="False"
                                          SelectionUnit="FullRow"
                                          gridtools:DataGridStyle.SelectAllButtonTemplate="{DynamicResource CisSelectAllButtonTemplate}"
                                          SelectedValuePath="."
                                          CanUserResizeColumns="True" 
                                          >
                                        <toolkit:DataGrid.RowDetailsTemplate>
                                            <DataTemplate>
                                                <risikoControls:RisikoDetails Risiko="{Binding ElementName=RisikenDataGrid, Path=SelectedValue}" />
                                            </DataTemplate>
                                        </toolkit:DataGrid.RowDetailsTemplate>

                                        <toolkit:DataGrid.Columns>
                                                <toolkit:DataGridTextColumn Binding="{Binding Path=Sortierung}" Header="Sortierung" />
                                                <toolkit:DataGridTextColumn Binding="{Binding Path=RisikoBezeichnung}" Header="Risiko" />
                                                <toolkit:DataGridTextColumn Binding="{Binding Path=Beschreibung}"  Header="Beschreibung" />
                                            </toolkit:DataGrid.Columns>
                                        </toolkit:DataGrid>
                                    </Grid>
                                </DataTemplate>

                        </toolkit:DataGrid.RowDetailsTemplate>

                        <toolkit:DataGrid.Columns>
                            <toolkit:DataGridTextColumn Binding="{Binding Path=LfdNr}" Header="LfdNr" />
                            <toolkit:DataGridTextColumn Binding="{Binding Path=Gruppe}" Header="Gruppe" />
                        </toolkit:DataGrid.Columns>

                    </toolkit:DataGrid>
                </Grid>
            </DataTemplate>

        </toolkit:DataGrid.RowDetailsTemplate>

        <toolkit:DataGrid.Columns>
            <toolkit:DataGridTextColumn Binding="{Binding Path=LfdNr}" Header="LfdNr" />
            <toolkit:DataGridTextColumn Binding="{Binding Path=Gruppe}" Header="Gruppe" />
        </toolkit:DataGrid.Columns>

    </toolkit:DataGrid>

So when I look at the compiled program, the child DataGrids show all Colums of the table I bound to them, not only the one I spezified. So, I hope you can help me.

A: 

It's a very simple Error, I just forgot the "AutoGenerateColums=false"Tag -.-

Tokk