We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Selected Cell Background

With VisualStyle="DefaultOffice2007Blue" for the GridDataControl,  when a cell is selected, the whole row will be highlighed with the cell's boarder become grey.
Is it possible to change the behavior to not highlight the row and only use Red for the selected cell's background color?


5 Replies

DR Deepak Raj Sundar Syncfusion Team July 8, 2014 11:58 AM UTC

Hai Yu,

Thanks for using Syncfusion products and sorry for the delay. It is possible to select a particular cell alone without highlighting other cells of same row, by setting  AllowSelection="Cell" and ListBoxSelectionMode="None" in the GridDataControl . In order to make the Background color of selected cell as red, you can create a resource dictionary and refer it in GridDataControl  resources.

Please refer the following code example :

Code Snippet[XAML] :

Inside File ‘Resource1.xaml’ :

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"



    <syncfusion:GridDataStyleManager x:Key="CustomGridDataStyleManager">


            <syncfusion:RowAppearence CurrentCellSelectionBackground="Red"                 

                                                               CurrentCellSelectionForeground="Black" />





Inside MainWindows.xaml :



     <ResourceDictionary  Source="/BasicSortingDemo;component/Resources/Resource1.xaml" />


<syncfusion:GridDataControl x:Name="dataGrid1"





                                        ItemsSource="{Binding ProductInfo}"



                                        ShowSortNumber="{Binding Path=IsChecked,


                                        StyleManager="{StaticResource CustomGridDataStyleManager}"

                                        VisualStyle="Office14Blue" >



Deepak raj Sundar

Attachment: CS_84e6a301.zip

YU Yu July 8, 2014 07:09 PM UTC

Hi, thanks for the reply.

Allowselection and listboxselectionmode work well to disable the row selection and only highlight the selected cell.

However, as we are binding the grid to a datatable as the datasource to allow dynamic number of columns during runtime, the style manager approach does not seem to work for changing the colours of selected cell. I also tried dynamic resource instead of static resource, but the cell colour still can not be changed. There is no column declaration in the xaml.

Will there be a work around for it? Also, is it possible to set the text alignment of these dynamic generated columns?


DR Deepak Raj Sundar Syncfusion Team July 15, 2014 06:39 AM UTC

Hai Yu,

Sorry for the delay caused. We have created a sample in which the data source is a Data Table and cell BackGround color is changed on selection.

Please refer the Sample attached and the following code snippet.


Code Snippet[Xaml]:

Inside the Dictionary1.xaml file :


<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"



    <syncfusion:GridDataStyleManager x:Key="CustomGridDataStyleManager">





                                        TextBlock.TextAlignment="Justify"  />


    </syncfusion:GridDataStyleManager >  



Please Let us know if you have any concern.



Deepak raj Sundar.

Attachment: Data_Table_Demo_13f15b5a.zip

YU Yu July 15, 2014 10:51 AM UTC

The sample works becuase it has the columns pre-dfined in the xaml.
If the columns definition are removed, and use the DataTable to generate the columns dynamics, the style settings will not work.
Could you please advise?

DR Deepak Raj Sundar Syncfusion Team July 17, 2014 11:39 AM UTC

Hi Yu,

We have modified the sample , without column definitions and we are getting the style settings i.e. the background color of selected cell gets changed to red.

Please have a look to the attached sample and let us know if you have any concern.


Deepak raj Sundar.

Attachment: Dynamic_Data_Table_Demo_57b68e4e.zip

Live Chat Icon For mobile
Up arrow icon