I have a treeview in wpf. I want a different color when i select the treeviewitem.
Any Suggestions Plz..
Thanks
I have a treeview in wpf. I want a different color when i select the treeviewitem.
Any Suggestions Plz..
Thanks
In the TreeView's ItemContainerStyle, define a trigger on the IsSelected property that will set the background color to whatever you want :
...
<TreeView.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Yellow"/>
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
...
Try following code. It should work.
<Style TargetType="{x:Type TreeViewItem}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Yellow"/>
</Trigger>
</Style.Triggers>
</Style>