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

[Solved] Setting selected row background color for specific grid controls

2 Answers 248 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roger
Top achievements
Rank 1
Roger asked on 01 Dec 2013, 07:51 PM
I am trying to change the background color shown when a user selects a row. I am able to get this working by adding the following to the App.xaml in Application.Resources:

      <SolidColorBrush x:Key="TelerikGridCurrentCellBackgroundBrush" Color="Transparent"/>
      <SolidColorBrush x:Key="TelerikGridSelectedBackgroundBrush" Color="#FF1186B0"/>

This sets those colors at a global level. I was hoping to set these at a per-page level, but adding these lines to the Resources section of a specific page does not have the same effect. It also does not make any effect if you add these lines to the Resources section of the grid control itself. Only when I add these lines to the App.xaml itself do I ever see the change.

So, how can I have different background color fills for selected rows for 2 different telerik grids in the same app? We have two totally differently styled grids on two different pages, but for now I must use the same selection color for both. Any suggestions?

2 Answers, 1 is accepted

Sort by
0
Accepted
Rosy Topchiyska
Telerik team
answered on 03 Dec 2013, 04:04 PM
Hi Roger,

Thank you for contacting us.

The Telerik named resources are useful when you wish to change the style of a control globally. If you wish to apply style on a per instance basis, then you can use implicit styling by defining the styles that target the grid elements you wish to customize in the Resources of the RadDataGrid instance. Here is an example of how to change the background of the current and the selected grid row/cell:
 
xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"
xmlns:telerikGridPrimitives="using:Telerik.UI.Xaml.Controls.Grid.Primitives"
 
<telerikGrid:RadDataGrid>
    <telerikGrid:RadDataGrid.Resources>
        <Style TargetType="telerikGridPrimitives:DataGridCurrencyControl">
            <Setter Property="Background" Value="Transparent"/>
        </Style>
        <Style TargetType="telerikGridPrimitives:SelectionRegionBackgroundControl">
            <Setter Property="Background" Value="Green"/>
        </Style>
    </telerikGrid:RadDataGrid.Resources>
 
</telerikGrid:RadDataGrid>

I hope this was useful. Please, let us know if you have further questions.

Regards,
Rositsa Topchiyska
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Roger
Top achievements
Rank 1
answered on 05 Dec 2013, 11:58 PM
Great, thanks so much.

-roger
Tags
Grid for XAML
Asked by
Roger
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Roger
Top achievements
Rank 1
Share this question
or