<DataGrid > <DataGrid.Columns> <DataGridTemplateColumn Header="C"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel> <Button x:Name="btnCollapse" ToolTip="Expand" Foreground="Black" Background="Transparent" BorderBrush="Transparent" Tag="{Binding LineItemKitsID}" > <Image Source="../images/Plus.png" Cursor="Hand" Height="20" Width="15" ></Image> </Button> </StackPanel> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="160*" Binding="{Binding GroupName}" Header="Group Name" Foreground="Black"> </DataGridTextColumn> </DataGrid.Columns> <DataGrid.RowDetailsTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <DataGrid Name="NestedDG"> <DataGrid.Columns> <DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="230" Binding="{Binding LineItem}" Header="Line Item" Foreground="Black"> </DataGridTextColumn> <DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="110" Binding="{Binding EffectiveDate}" Header="Effective Date" Foreground="Black"> </DataGridTextColumn> </DataGrid.Columns> </DataGrid> </StackPanel> </DataTemplate> </DataGrid.RowDetailsTemplate>
RowDetailsVisibilityChanged
protected void ParentDG_RowDetailsVisibilityChanged(object sender, DataGridRowDetailsEventArgs e) { DataGrid nestedGrid = (DataGrid)e.DetailsElement.FindName("NestedDG"); if (e.Row.DetailsVisibility == Visibility.Visible) { nestedGrid.ItemsSource = dsKitDetails.Tables[0].DefaultView; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)