Offset of the grouping in the DataGrid table

58 views Asked by At

I have grouped the data into two columns of the table. But I don't like the way it looks. The second grouping is almost under the first one. How to make it shifted to the right? Is it possible to make it strictly in the second column?

<Window.Resources>
        <CollectionViewSource x:Key="GroupedData" Source="{Binding ToleranceStandard.StandardElements}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Classification" />
                <PropertyGroupDescription PropertyName="DimensionType" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
    </Window.Resources>

<DataGrid x:Name="dataGrid"
                  AutoGenerateColumns="False"
                  HeadersVisibility="Column"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserResizeRows="False"
                  ItemsSource="{Binding Source={StaticResource GroupedData}}">
       
            <DataGrid.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander IsExpanded="True">
                                            <Expander.Header>
                                                <TextBlock Margin="5 0 0 0"
                                                           FontWeight="Bold"
                                                           Text="{Binding Name}" />
                                            </Expander.Header>
                                            <Expander.Content>
                                                <ItemsPresenter />
                                            </Expander.Content>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>
            <DataGrid.Columns>
             ,,,,
            </DataGrid.Columns>

image image

I tried setting up the Margin but it didn't help as the groupings are related and shift together.

0

There are 0 answers