Monday, June 20, 2011

WPF Selected Treeview Item Background

This one took me a while to figure out, so I thought I’d share it with everyone. If you have a treeview item and don’t want the selected item to be that ugly blue color, you can easily change it.

 

All you need to do is add this line of code into your Treeview. In this particular example, I didn’t want the selected item to be colored at all, so I set the color to Transparent, but you can enter other colors here to suit your app’s needs.

Hope this helps. Happy coding!

                    <TreeView.Resources>
<
SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
</
TreeView.Resources>



2 comments:

  1. awesome, quick fix! Gonna test it out.

    ReplyDelete
    Replies
    1. That's working, and it's great! Thank you! (Ofer)

      Delete