Question

I have a DevExpress grid that has some editable columns. Would like the user to know easily they are editable so thought about changing the column header to 'Bold'.

<dxg:GridControl.Columns>
    <dxg:GridColumn Header="Region" FieldName="Region" ReadOnly="False" Style="{StaticResource DxEditableColumnsStyle}" />
    <dxg:GridColumn Header="Id" FieldName="Id" ReadOnly="True" Style="{StaticResource DxColumnsStyle}"/>
    <dxg:GridColumn Header="Entity" FieldName="Entity" ReadOnly="False" Style="{StaticResource DxEditableColumnsStyle}"/>
</dxg:GridControl.Columns>

Woudl you know how to do so? I've tried updating this through some setters in my dictonnary but it doesn't work:

<Style TargetType="dxg:GridColumn" x:Key="DxEditableColumnsStyle">
    <Setter Property="CellStyle">
        <Setter.Value>
            <Style TargetType="{x:Type dxg:GridColumn}">
                <Setter Property="TextBlock.FontWeight" Value="Bold" />
            </Style>
        </Setter.Value>
    </Setter>
</Style>

thank you!

Was it helpful?

Solution

To accomplish this task, I suggest that you use the TableView.ColumnHeaderContentStyle property. In this style, you can bind the TextBlock.FontHeight attached property to the GridColumn.ReadOnly property (via converter):

<dxg:TableView.ColumnHeaderContentStyle>
    <Style TargetType="dxg:HeaderContentControl">
        <Setter Property="TextBlock.FontHeight" Value="{Binding ReadOnly, Converter={StaticResource YourReadOnlyToFontHeightConverter}}"/>
    </Style>
</dxg:TableView.ColumnHeaderContentStyle>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top