New to Telerik UI for WPF? Download free 30-day trial

Selection Color is not Respected when CellStyle or CellStyleSelector is Applied

Environment

Product Version 2020.2.617
Product RadGridView for WPF

Description

The selection background is not shown when a custom CellStyle or CellStyleSelector is applied.

Solution

When a CellStyle or CellStyleSelector is applied, the background of the cells set through the CellStyle property overrides the selection background color of the GridViewRow.

To display the selection color instead of the custom background set for the cells, you can define a DataTrigger bound to the IsSelected property of the parent row.

<Style x:Key="CellStyle" TargetType="telerik:GridViewCell" BasedOn="{StaticResource GridViewCellStyle}"> 
    <Setter Property="Background" Value="Red" /> 
    <Style.Triggers> 
        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=telerik:GridViewRow}}" Value="True"> 
            <Setter Property="Background" Value="{Binding Background}" /> 
        </DataTrigger> 
    </Style.Triggers> 
</Style> 

See Also

In this article