Change RadGridView current cell focus style

3 posts, 1 answers
  1. Mohammed
    Mohammed avatar
    9 posts
    Member since:
    Jul 2014

    Posted 30 Nov 2014 Link to this post

    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. Answer
    Boris
    Admin
    Boris avatar
    276 posts

    Posted 01 Dec 2014 Link to this post

    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.

     
  3. Mohammed
    Mohammed avatar
    9 posts
    Member since:
    Jul 2014

    Posted 01 Dec 2014 in reply to Boris Link to this post

    Thanks Boris , IsCurrent trigger solved my issue .
Back to Top