How to set SelectedBackground in TreeListView

0 Answers 56 Views
TreeListView
J
Top achievements
Rank 1
J asked on 07 Nov 2024, 11:50 AM | edited on 07 Nov 2024, 11:16 PM

I want to set backgound of selected row in RadTreeListView. I tried below, but it does not work. 

I'm applying a theme to my application using no-xaml. When using a theme, is it not possible to change the background?

            <Style TargetType="telerik:TreeListViewRow" BasedOn="{StaticResource TreeListViewRowStyle}">
                <Style.Triggers>
                    <Trigger Property="IsSelected" Value="True">
                        <Setter Property="SelectedBackground" Value="#FFFFBB00" />
                        <Setter Property="Background" Value="#FFFFBB00"/>
                    </Trigger>
                </Style.Triggers>
            </Style>


Stenly
Telerik team
commented on 11 Nov 2024, 09:14 AM

Hello,

Before continuing, could you share the theme that is applied on your end? This will allow me to review the RadTreeListView control's default Style and ControlTemplate for this theme and suggest an approach for achieving the desired behavior.

J
Top achievements
Rank 1
commented on 12 Nov 2024, 01:49 AM

I'm using the Expression_Dark theme.
Martin Ivanov
Telerik team
commented on 12 Nov 2024, 01:02 PM

The SelectedBackground property is not support in RadTreeListView. This is logged in our feedback portal.

To achieve your requirement in the Expression_Dark theme, you can extract and modifying the ControlTemplate of TreeListViewRow.

If you switch to a newer theme - Material or later - you can use the ThemeHelper class and its CheckedBrush attached property, like so:

         <Style TargetType="telerik:TreeListViewRow" BasedOn="{StaticResource TreeListViewRowStyle}">
                <Setter Property="helpers:ThemeHelper.CheckedBrush" Value="#FFFFBB00" />
          </Style>

You can see this shown in the attached project, which uses the Office2019 theme with its Dark color variation applied.

J
Top achievements
Rank 1
commented on 12 Nov 2024, 11:58 PM

Thank you for the answer!

No answers yet. Maybe you can help?

Tags
TreeListView
Asked by
J
Top achievements
Rank 1
Share this question
or