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

Change RadGridView current cell focus style

2 Answers 623 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mohammed
Top achievements
Rank 1
Mohammed asked on 30 Nov 2014, 01:48 PM
Hello all , 

Can I change the style of selected current cell instead of default focus .

I used the following xaml :

 <telerik:RadGridView.Resources>
                <Style  TargetType="telerik:GridViewCell">
                    <Style.Triggers>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter Property="Background" Value="#6F0090FF"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
</telerik:RadGridView.Resources>



but I found it change background of selected row instead of selected cell .

2 Answers, 1 is accepted

Sort by
0
Accepted
Boris
Telerik team
answered on 01 Dec 2014, 03:39 PM
Hello Mohammed,

In your case by changing the Background color of the selected GridViewCell affects the whole GridViewRow because by default the SelectionUnit property of RadGridView is set to "FullRow". This means that all the cells in that row are selected and that is why they are visually changed. In addition there are two additional unit types and different SelectionModes, which will also be affected by modifying the Background color of the selected cell. For more information about them, you can check the Basic Selection article.

A possible way to customize the style of the selected GridViewCell or GridViewRow is to edit respectfully the GridViewCellTemplate or GridViewRowTemplate templates. There you can customize the Border element with x:Name="Background_Selected" and the contained inner Border element. 

Please keep in mind that if you need the SelectionUnit property of RadGridView to stay set to "FullRow" and change the style only of the current cell (which is focused), you will need to find the Border element with x:Name="Background_Current", which is located in the GridViewCellTemplate. Another possible way to change the Background color of the current cell is to use your approach, the only difference will be that you will be using the IsCurrent trigger property instead of IsSelected.

For more information about themes and how to edit a ControlTemplate, you can check the Setting a Theme (Using Implicit Styles) and Editing Control Templates documentation articles. In addition you can check the Override the Default RadGridView Styles article.

I hope this helps.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Mohammed
Top achievements
Rank 1
answered on 01 Dec 2014, 09:06 PM
Thanks Boris , IsCurrent trigger solved my issue .
Tags
GridView
Asked by
Mohammed
Top achievements
Rank 1
Answers by
Boris
Telerik team
Mohammed
Top achievements
Rank 1
Share this question
or