Search code examples
xamldatagridstylingrowdetails

How to style row header column in DataGrid


I am using ComponentOne C1DataGrid. I have been able to style it to the full extent except row header column.

How can I style it in XAML?

You can see the image: here Thanks, flot


Solution

  • Answering my own question in case somebody else is interesting:

    There is a special presenter, DataGridRowHeaderPresenter, that can be styled. I wanted to replace a standard row details toggle with the tree-like "+" and "-" signs and I did it as follows:

        <Style x:Key="DataGridRowHeaderStyle2" TargetType="{x:Type c1:DataGridRowHeaderPresenter}">
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type c1:DataGridRowHeaderPresenter}">
                    <!-- BulletDecorator is used to provide baseline alignment between the sign and the Content -->
                    <BulletDecorator Background="#BFEFF2F5">
                        <BulletDecorator.Bullet>
                            <Grid Width="13" Height="13">
                                <Image Name="sign" Source="/myControls;component/Resources/Images/plus.png" />
                            </Grid>
                        </BulletDecorator.Bullet>
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                    </BulletDecorator>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Source"  Value="/myControls;component/Resources/Images/minus.png"  TargetName="sign"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>