How to disable or overwrite background brush for selection in the TreeView?

1 Answer 44 Views
TreeView
Kostiantyn
Top achievements
Rank 1
Iron
Kostiantyn asked on 25 Oct 2023, 11:47 AM

How to disable or overwrite background brush for selection in the TreeView?

What kind of templates I will be need to rewrite? Cause there's template for RadTreeViewItem  but I cannot reach this brush.

1 Answer, 1 is accepted

Sort by
0
Dinko
Telerik team
answered on 26 Oct 2023, 10:17 AM

Hello Kostiantyn,

To achieve the desired result, you can edit the default MaterialAssist.CheckedBrush value to change the color of the RadTreeViewItem when the item is selected. After making this change the item still have this blue background when you hover over it. In order to change this background color, you can edit the MaterialAssist.MouseOverBrush by using the IsSelected trigger property of the RadTreeViewItem.

<Style TargetType="telerik:RadTreeViewItem">
	<Setter Property="mat:MaterialAssist.CheckedBrush" Value="Red"/>
	<Style.Triggers>
		<Trigger Property="IsSelected" Value="True">
			<Setter Property="mat:MaterialAssist.MouseOverBrush" Value="Red"/>
		</Trigger>
	</Style.Triggers>
</Style>

This is the result after the changes:

For your convenience I prepared a sample solution where this behavior is implemented.

Regards,
Dinko
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
TreeView
Asked by
Kostiantyn
Top achievements
Rank 1
Iron
Answers by
Dinko
Telerik team
Share this question
or