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
1065
Selected cell colour changed not as expected
posted

Hello,

I have the below code to change cell colour when the cell is selected:

 

 

 

 

 

 

 

 

 

 

 

<Style TargetType="{x:Type igDP:CellValuePresenter}">        
            <Setter Property="Background" Value="White" />
        
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="true">
                    <Setter Property="Background" Value="Red" />
                </Trigger>           
            </Style.Triggers>
</Style>

In the above example, I want the cell colour to be changed to red when the cell is selected. But the selected cell colour turned out to be gridient from light blue to red (Please see the attached screenshot). I have tried this style in a few xamDataGrids, but they all turned out to be the same.

Any idea why this might happen and how to fix?

Thanks.

  • 9836
    Verified Answer
    posted

    The blue color is related to the active cell's default brush. You can try with one of the following styles:

    <Style TargetType="{x:Type igDP:CellValuePresenter}">

    <Setter Property="BackgroundActive" Value="Transparent" />

    <Setter Property="BackgroundSelected" Value="Red" />

    </Style>

    <Style TargetType="{x:Type igDP:CellValuePresenter}">

    <Setter Property="BackgroundActive" Value="Transparent" />

    <Setter Property="Background" Value="White" />

    <Style.Triggers>

    <Trigger Property="IsSelected" Value="true">

    <Setter Property="Background" Value="Red" />

    </Trigger>

    </Style.Triggers>

    </Style>

    Hope this helps.