We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Stacked Header Hight changes unexpectedly

Hi

How to fix this "staircase" effect? (I want all of the stacked headers to be at the same height)

code:

.xaml:


<Syncfusion:SfDataGrid x:Name="resultGrid"
                                                       MaxHeight="300"
                                                       Margin="0,3, 7, 0"
                                                       AutoGenerateColumns="False"
                                                       SelectionMode="Single"
                                                       ItemsSource="{Binding AnalysisResultRows}"
                                                       RowSelectionBrush="#E1ECFF"
                                                       LiveDataUpdateMode="AllowDataShaping"
                                                       HeaderRowHeight="40"
                                                       AllowSorting="False"
                                                       ColumnSizer="Star"
                                                       FontSize="22"
                                                       HorizontalAlignment="Stretch"
                                                       VerticalAlignment="Stretch"
                                                       GridValidationMode="InEdit"
                                                       GridPasteOption="None"
                                                       GridCopyOption="None"
                                                       >
</Syncfusion:SfDataGrid>

.xaml.cs (code behind):

if (null != DataContext)
{
    AnalysisResultViewModel viewModel = (AnalysisResultViewModel)DataContext;


    resultGrid.Columns.Add(new GridTextColumn()
    {
        HeaderText = "File Name",
        MappingName = "FileName",
    });


    resultGrid.Columns.Add(new GridTextColumn()
    {
        HeaderText = "Filter",
        MappingName = "Filter",
    });


    resultGrid.Columns.Add(new GridNumericColumn()
    {
        HeaderText = "Intensity",
        MappingName = "Intensity",
    });


    for (int i = 0; i < viewModel.SensorNames.Count(); i++)
    {
        resultGrid.Columns.Add(new GridNumericColumn()
        {
            HeaderText = "Intensity",
            MappingName = $"SensorIntensities[{i}]",
        });


        resultGrid.Columns.Add(new GridNumericColumn()
        {
            HeaderText = "Statistical Error",
            MappingName = $"SensorStatisticalErrors[{i}]",
        });


        StackedHeaderRow shr = new StackedHeaderRow();


        shr.StackedColumns.Add(new StackedColumn()
        {
            ChildColumns = $"SensorIntensities[{i}],SensorStatisticalErrors[{i}]",
            HeaderText = viewModel.SensorNames.ElementAt(i),
        });


        resultGrid.StackedHeaderRows.Add(shr);
    }
}


result:



2 Replies

SS Sethuramkumar Senthilkumar Syncfusion Team December 5, 2022 12:35 PM UTC

Hi Shai Ben-Gigi,


Currently we are validating the reported issued from our end. We will analyze and update you with further details on or before December 7, 2022.

Regards,
Sethuramkumar Senthilkumar.



DM Dhanasekar Mohanraj Syncfusion Team December 7, 2022 03:11 PM UTC

Shai Ben-Gigi,


We have checked the reported issue with the provided details. The reported scenario is not an issue, the stacked header rows were added multiple times based on the Iteration that’s why it showed like the shared screenshot. In the provided code snippet, you are adding the new StackedHeaderRows for every StackedColums that caused the reported problem. You should add all the StackedColumns into one StackedHeaderRow shown in the below user guide documentation,

UG Link: https://help.syncfusion.com/wpf/datagrid/stacked-headers?cs-save-lang=1&cs-lang=csharp


Loader.
Live Chat Icon For mobile
Up arrow icon