Hjalte Tagmose
Hjalte Tagmose

Reputation: 67

Xceed DataGrid: Remove spacing above detail rows

enter image description here

How can I remove this spacing Xceed automatically puts in before detail rows? Normally there's a title here but I set it to nothing as I didn't want it. The spacing marked red is the most annoying.

I found that replacing this line:

                <xcdg:DetailConfiguration RelationName="Settings" Title="">

With this line:

            <xcdg:DetailConfiguration RelationName="Settings" Title="" UseDefaultHeadersFooters="False">

Will remove the space marked red. However it also removed my header:

| Name | Description | Edit Values | Edit Value |

Here's my code:

<UserControl.Resources>

    <!--#region DataTemplateSelector-->
    <local:SettingsDataTemplateSelector x:Key="SettingsDataTemplateSelector" />

    <DataTemplate x:Key="TextboxDataTemplate">
        <xcdg:MaskedTextBox IsTabStop="True" Mask="{Binding EditMask}" Text="{Binding EditValue, IsAsync=False, Mode=TwoWay, UpdateSourceTrigger=LostFocus, ValidatesOnExceptions=True}"/>
    </DataTemplate>

    <DataTemplate x:Key="ComboDataTemplate">
        <ComboBox IsTabStop="True"  ItemsSource="{Binding Path=SelectionValues}"
                                    SelectedValuePath="Value"
                                    SelectedValue="{Binding Path=SelectionValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                    DisplayMemberPath="ValueText">
        </ComboBox>
    </DataTemplate>

    <DataTemplate x:Key="SliderDataTemplate">
        <Slider IsTabStop="True" Value="{Binding EditSliderValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                    Minimum="{Binding MinRangeValue}" 
                    Maximum="{Binding MaxRangeValue}"
                    VerticalAlignment="Bottom" 
                    IsSnapToTickEnabled="True"
                    TickFrequency="1"
                    Margin="0,0,0,0"/>
    </DataTemplate>
    <!--#endregion-->

    <xcdg:DataGridCollectionViewSource x:Key="Features" 
                                        Source ="{Binding Path=Demo.Features}"
                                        AutoFilterMode="And"
                                        AutoCreateDetailDescriptions="False" 
                                        AutoCreateItemProperties="False">
        <xcdg:DataGridCollectionViewSource.DetailDescriptions>
            <xcdg:PropertyDetailDescription RelationName="Settings" AutoCreateDetailDescriptions="False" AutoCreateItemProperties="False"/>
        </xcdg:DataGridCollectionViewSource.DetailDescriptions>
    </xcdg:DataGridCollectionViewSource>
</UserControl.Resources>

<Grid>
    <!--#region Xceed DataGrid-->
    <xcdg:DataGridControl x:Name="datagrid"
                          ItemsSource="{Binding Source={StaticResource Features}}"
                          KeyUp="DatagridKeyUp"
                          AllowDetailToggle="True" 
                          Margin="10"
                          NavigationBehavior="RowOrCell" 
                          CellEditorDisplayConditions="RowIsBeingEdited, 
                          MouseOverCell, MouseOverRow, RowIsCurrent, CellIsCurrent" 
                          EditTriggers="BeginEditCommand, ClickOnCurrentCell, 
                          SingleClick, CellIsCurrent, ActivationGesture, RowIsCurrent"
                          ItemScrollingBehavior="Immediate"
                          AutoCreateColumns="False">

        <xcdg:DataGridControl.Resources>
            <Style TargetType="xcdg:TableViewScrollViewer">
                <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
                <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
            </Style>
        </xcdg:DataGridControl.Resources>

        <xcdg:DataGridControl.View>
            <xcdg:TableflowView UseDefaultHeadersFooters="False" ColumnStretchMode="Last">
                <xcdg:TableflowView.FixedHeaders>
                    <DataTemplate>
                        <xcdg:ColumnManagerRow />
                    </DataTemplate>
                </xcdg:TableflowView.FixedHeaders>
            </xcdg:TableflowView>
        </xcdg:DataGridControl.View>

        <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="FeatureID" Title="FeatureID" ReadOnly="True" />
            <xcdg:Column FieldName="Name" Title="Feature name" ReadOnly="True" />
            <xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
            <xcdg:Column FieldName=" "/>
        </xcdg:DataGridControl.Columns>

        <xcdg:DataGridControl.DetailConfigurations>
            <xcdg:DetailConfiguration RelationName="Settings" Title="">
                <xcdg:DetailConfiguration.Columns>
                    <xcdg:Column FieldName="Name" Title="Name" ReadOnly="True"/>
                    <xcdg:Column FieldName="Description" Title="Description" ReadOnly="True"/>
                    <xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True"/>
                    <xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
                                 CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
                                 DisplayMemberBinding="{Binding}" />
                    <xcdg:Column FieldName=" "/>
                </xcdg:DetailConfiguration.Columns>
            </xcdg:DetailConfiguration>
        </xcdg:DataGridControl.DetailConfigurations>
    </xcdg:DataGridControl>
    <!--#endregion-->
</Grid>

EDIT: I figured out how to get rid of the blue spacing, but still can't figure out how to get rid of the red.

Code:

<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
    <Setter Property="MaxWidth" Value="0" />
</Style>

You might think that you could add <Setter Property="MaxHeight" Value="0" />, but that does nothing.

Upvotes: 0

Views: 557

Answers (1)

Hjalte Tagmose
Hjalte Tagmose

Reputation: 67

The blue spacing is set by the HierarchicalGroupLevelIndicatorPane, which means you can get rid of it by simply setting the width to 0:

<Style TargetType="xcdg:HierarchicalGroupLevelIndicatorPane" >
    <Setter Property="MaxWidth" Value="0" />
</Style>

The red spacing was a bit more difficult. In the end I set UseDefaultHeadersFooters to false on the DetailConfiguration, which removes the space but also the ColumnManagerRow. Then I create the ColumnManagerRow again inside the DetailConfiguration.Headers.

The code looks like this:

       <xcdg:DataGridControl.DetailConfigurations>
            <xcdg:DetailConfiguration RelationName="Settings" UseDefaultHeadersFooters="False">

                <xcdg:DetailConfiguration.Headers>
                    <DataTemplate>
                        <xcdg:ColumnManagerRow />
                    </DataTemplate>
                </xcdg:DetailConfiguration.Headers>

                <xcdg:DetailConfiguration.Columns>
                    <xcdg:Column FieldName="Name" Title="Name" ReadOnly="True" />
                    <xcdg:Column FieldName="Description" Title="Description" ReadOnly="True" />
                    <xcdg:Column FieldName="EditValues" Title="Edit Values" ReadOnly="True" />
                    <xcdg:Column FieldName="EditValueVar" Title="Edit Value" Width="150" ReadOnly="False"
                                 CellContentTemplateSelector="{StaticResource SettingsDataTemplateSelector}"
                                 DisplayMemberBinding="{Binding}" />
                    <xcdg:UnboundColumn FieldName=" " />
                </xcdg:DetailConfiguration.Columns>

            </xcdg:DetailConfiguration>
        </xcdg:DataGridControl.DetailConfigurations>

Upvotes: 1

Related Questions