First, Sorry my english....but i don't know english very well...
So, you can implement this doing this code in XAML:
<WpfToolkit:DataGrid Name="dgSysthetic" ItemsSource="{Binding}"
AutoGenerateColumns="True"
SelectionMode="Extended"
RowDetailsVisibilityMode="Collapsed"
CanUserAddRows="False" CanUserDeleteRows="False"
CanUserResizeRows="False" CanUserSortColumns="False"
RowHeaderWidth="20" RowHeight="25">
<WpfToolkit:DataGrid.RowHeaderTemplate>
<DataTemplate>
<Button Name="btnHideRow" Click="btnHideDetails_Click" FontSize="5">></Button>
</DataTemplate>
</WpfToolkit:DataGrid.RowHeaderTemplate>
<WpfToolkit:DataGrid.RowDetailsTemplate>
<DataTemplate>
<WpfToolkit:DataGrid Name="dgAnalytical" ItemsSource="{Binding}" AutoGenerateColumns="True"/>
</DataTemplate>
</WpfToolkit:DataGrid.RowDetailsTemplate>
</WpfToolkit:DataGrid>
See the button inside RowHeaderTemplate.
In cs you do this code:
private void btnHideDetails_Click(object sender, RoutedEventArgs e)
{
DependencyObject obj = (DependencyObject)e.OriginalSource;
while (!(obj is DataGridRow) && obj != null) obj = VisualTreeHelper.GetParent(obj);
if (obj is DataGridRow)
{
if ((obj as DataGridRow).DetailsVisibility == Visibility.Visible)
{
(obj as DataGridRow).DetailsVisibility = Visibility.Collapsed;
}
else
{
(obj as DataGridRow).DetailsVisibility = Visibility.Visible;
}
}
}
This worked very well to me, try and reply if works for you in [email protected] thks!