Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
225
DataRecordCellArea Styling fails when Themes applied
posted

This works -

  <Grid>
        <Grid.Resources>
            <local:SearchResultConverter x:Key="SearchConverter" />
            <Style TargetType="{x:Type igDP:DataRecordCellArea}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem, Converter={StaticResource SearchConverter}}" Value="True">
                        <Setter Property="Background" Value="LightGray" />
                        <Setter Property="FontWeight" Value="Bold" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
 
        <igDP:XamDataGrid Name="resultsGrid" />
    </Grid>

This doesn't -

 

  <Grid>
        <Grid.Resources>
            <local:SearchResultConverter x:Key="SearchConverter" />
            <Style TargetType="{x:Type igDP:DataRecordCellArea}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.DataItem, Converter={StaticResource SearchConverter}}" Value="True">
                        <Setter Property="Background" Value="LightGray" />
                        <Setter Property="FontWeight" Value="Bold" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
 
        <igDP:XamDataGrid Name="resultsGrid" Theme="Aero"/>
    </Grid>

Why?  All I'm trying to do is to style one row based on a hidden column - it's so hard!

 

  • 69686
    Suggested Answer
    posted

    Hello,

    The style is not failing, it is just never applied. This is because the WPF Framework supports only one local style. When you are setting a Theme, in the XamDataGrid's resouces there are defined styles that the themes uses. This will prevent any styles further in the ancestor's chain to be applied, because once the element has found a style, it stops looking for another one.

    What you can do is put the style inside the XamDataGrid's resouces. This way the style would be applied. You can see this explained in more detail by Andrew Smith