How to disable highlighting on listbox but keep selection?

前端 未结 7 1162
盖世英雄少女心
盖世英雄少女心 2020-11-30 02:18

I am having trouble finding how to not allow my ListBox to highlight the item selected. I know that I didn\'t add a trigger to highlight the item.



        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 02:50

    Late answer, but there's a much better and simpler solution:

    
       
          
          
            
       
    
    

    This allows you to have a LisBox that looks just like an itemscontrol, but has support for selection.

    Edit: How it works
    This alters "colors of the system", in other words your windows theme, only for this ListBox and its children (we actually want to target the ListboxItem).

    For example hovering a ListboxItem usually gives it a deep blue background, but here we set it to transparent (HighlightBrushKey).

    Edit (30 June 2016):
    It seems for latest Windows version this is not enough anymore, you also need to redefine InactiveSelectionHighlightBrushKey

    
    

    Thanks to @packoman in the comments

提交回复
热议问题