How to change the background color of selected rows in treelistview?

0 Answers 86 Views
TreeListView
YunFan
Top achievements
Rank 1
YunFan asked on 01 Aug 2024, 06:33 AM

        <Style TargetType="telerik:TreeListViewRow">
            <Setter Property="SelectedBackground" Value="Red"/>
        </Style>

I set the SelectedBackground property, but it didn't work. I hope you can tell me what to do?

Stenly
Telerik team
commented on 01 Aug 2024, 07:37 AM

Hello YunFan,

May I ask if you could share a bit more information about this case? More specifically, what is the used theme on your end? This way, I will review the default style for the TreeListViewRow for the theme that you use and share possible solutions for achieving the desired behavior.

YunFan
Top achievements
Rank 1
commented on 02 Aug 2024, 01:07 AM | edited

The theme is CrystalTheme and the version is 2022.2.511.60
Stenly
Telerik team
commented on 02 Aug 2024, 11:53 AM

Hello YunFan,

For the Crystal theme, the selected color of the TreeListViewRow element is controlled by the MaterialAssist.CheckedBrush attached property.

With this in mind, to change the selected color, create a new Style with TargetType="TreeListViewRow" and add a new Setter for the MaterialAssist.CheckedBrush property and set it to the desired color.

The namespace for the MaterialAssist class is as follows:

xmlns:mat="clr-namespace:Telerik.Windows.Controls.MaterialControls;assembly=Telerik.Windows.Controls"

The following code snippet shows this suggestion's implementation:

<!--If NoXaml assemblies version is used: BasedOn="{StaticResource TreeListViewRowStyle}"-->
<Style TargetType="telerik:TreeListViewRow">
    <Setter Property="mat:MaterialAssist.CheckedBrush" Value="red"/>
</Style>

The following code snippet shows the produced result:

I hope the provided information will be of help to you.

No answers yet. Maybe you can help?

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