SelectedBackground for Alternate Row

1 Answer 100 Views
GridView
Paul
Top achievements
Rank 2
Iron
Iron
Iron
Paul asked on 16 Jan 2023, 04:26 PM

On GridViewRow I have a style that sets SelectedBackground but it does not work on the alternate rows.

xaml example

<Setter Property="SelectedBackground"
                    Value="Yellow" />

Is there another property that I need to set so that it will also use the SelectedBackground  color when I select an alternate row

(I guessed SelectedAlternateBackground but this isn't present)

 

Thanks

1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 17 Jan 2023, 04:06 PM

Hello Paul,

To achieve this requirement, you could create a custom Style for the AlternateRowStyle property of RadGridView and set the SelectedBackground to the desired color. By doing so, the value set to the SelectedBackground property will be applied only to the alternating rows.

The following snippets show this suggestion's implementation:

<Style x:Key="AlternateGridViewRowStyle" TargetType="telerik:GridViewRow">
    <Setter Property="Background" Value="LightGray"/>
    <Setter Property="SelectedBackground" Value="Green"/>
</Style>
<telerik:RadGridView ItemsSource="{Binding People}" AlternationCount="2" AlternateRowStyle="{StaticResource AlternateGridViewRowStyle}"/>

The produced result is as follows:

Could you give this suggestion a try?

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Paul
Top achievements
Rank 2
Iron
Iron
Iron
commented on 19 Jan 2023, 10:09 AM

Brilliant, that's exactly what I was looking for.
Tags
GridView
Asked by
Paul
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or