WPF TreeViewItem Background

后端 未结 3 974
难免孤独
难免孤独 2021-01-07 05:03

How can I change the Background of a selected TreeViewItem when the TreeView (or the Application) looses Focus. A selected item by def

3条回答
  •  时光取名叫无心
    2021-01-07 05:21

    More easy way for your particular case exists. Like in ListBox, you can replace ControlBrush resource for TreeViewItem's using style:

    
    

    You can specify any other color. Opacity is suggested because if your have several TreeView/ListBox you can determine which one is focused. But of course, editing full style can bring you much more flexibility for future customizations.

    Sample with gradients:

    
    

提交回复
热议问题