I want to style a cell in a RadGridView so whenever the cell turns into edit mode the backgroundcolor is e.g. yellow.
<telerik:RadGridView x:Name="Name" SelectionUnit="Cell">
<telerik:RadGridView.Resources>
<Style TargetType="telerik:GridViewCell">
<Style.Triggers>
<Trigger Property="IsInEditMode" Value="True">
<Setter Property="Background" Value="Yellow"/>
</Trigger>
</Style.Triggers>
</Style>
</telerik:RadGridView.Resources>
</telerik:RadGridView>
This doesn't do anything.
As mentioned in the comments, the GridViewCell
, when editable, displays a TextBox
that consumes the entire space the GridViewCell
has available; so setting the background of the GridViewCell
does nothing, because you can't see the background of the GridViewCell
. The solution is to change the background of the control that is displayed while the GridViewCell
is editable, thus we need to change the Background
of the TextBox
.
In the RadGridView
do the following:
<telerik:RadGridView.Resources>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Background" Value="LightYellow"/>
</Style>
</telerik:RadGridView.Resources>
It changes the background color of each selected-to-edit Cell to LightYellow
.