This is a migrated thread and some comments may be shown as answers.

Access column properties from header style

1 Answer 42 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pablo
Top achievements
Rank 1
Pablo asked on 31 May 2016, 02:21 PM

Hello team,

I'm trying to acces IsReadOnly property from header style to change its foreground color. For now, I didn't find a solution. I'm trying the following:

<Style x:Key="GridViewHeaderCellStyle" TargetType="{x:Type telerik:GridViewHeaderCell}">

...

<Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewDataColumn}}, Path=Column.IsReadOnly}" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource primaryBrush}" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 03 Jun 2016, 08:57 AM
Hello Pablo,

To achieve the desired behavior, you should set the RelativeSourceMode to Self. For reference, please take a look at code snippet below:
<telerik:RadGridView.Resources>
                <Style TargetType="{x:Type telerik:GridViewHeaderCell}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Column.IsReadOnly}" Value="True">
                            <Setter Property="Foreground" Value="Red" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
</telerik:RadGridView.Resources>

I hope that this helps.


Regards,
Martin Vatev
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Pablo
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or