I have a RadGridVIew in which I use the color of rows to indicate a certain property of the row data (e.g. order, invoice, delivery slip etc.).
When the user selects a row the row will be yellow.
My question is how can I change this, the user wants to see the color of the row and a blue border to indicate which row is selected.
I looked at different threads but didnt find any solution.
The style that I use for the GridViewRow is shown below:
Any help would be greatly appreciated.
8 Answers, 1 is accepted
In order to change the selected row's appearance you'll need to predefine the template. You can extract it using Blend for Visual Studio (or Expression Blend if you are using an older version of Visual Studio). This page in the documentation will show you the steps needed within the "Modifying the Default Style" section.
In particular, you'll want to modify the Background_Selected element. Since the Background_Selected element is a Border, you'll need to target the Fill property instead of a Background property.
I have used your code and have written a sample application (attached) that achieves what you're looking for. I moved your Style Triggers to the new RowStyle in Windows.Resources. Look for my two code comments in the template that highlight the changes I made to the default style.
Thank you for contacting Support and thank you for choosing Telerik.
Thank you for the provided image.
The cell to which you refer is the CurrentCell of RadGridView. Speaking generally, the control can have multiple selected items, but cannot have multiple current cells. May I kindly ask you to share some additional information regarding the behavior you are aiming at? Is it just related to the visual appearance of the control?
Thanks for your reply.
I need same behavior as given sample(GridViewSelection.zip) with below changes,
1. Sample does not support multi row selection.
2. In provided sample, If you want to select a row (item) in the grid it highlight only cell (SampleBehaviour.png). But my requirement is select whole row (ExpectedBehavior.png) and should be able to select multiple rows.
3. Selected rows should be highlighted using item border (ExpectedBehavior.png)
Such behavior can be achieved by modifying the template of GridViewRow and its Border named Background_Selected in particular. Attached to my reply you can find a sample application I prepared for your convenience that demonstrates the approach. Can you please check it out? You should be able to see that I have commented our the inner Border used within the aforementioned element. Thus, only the outer Border will be visualized. Furthermore, you can modify the BorderBrush that is used for it.
Additionally, you may find the following topics useful on this matter.
- Editing Control Templates
- Setting a Theme
I hope this helps.
This is the feature needed. Thanks for the grate support and for the references.
Appreciate your help.
The framework allows Style inheritance, but the same cannot be achieved with templates. So, when customizing the template of a given element its whole template has to be extracted. I would also like to clarify, that with our next official R3 2018 release we will expose the SelectedBackground property of GridViewRow. With it setting the Background of the selected row would not require editing the whole template of the row.