DataGrid's selected row color when inactive

前端 未结 11 1332
轻奢々
轻奢々 2020-12-04 23:31

How can I style WPF DataGrid to change the color of selected row when DataGrid lost its focus?

11条回答
  •  渐次进展
    2020-12-04 23:51

    After ages of searching, I found a surprisingly simple way to do this that's cleaner than the Got/LostFocus approach posted earlier:

    
        
    
    

    This just sets the inactive background colour to DarkGray, leaving the active background colour to the default, but you can change that too using the SystemColors.HighlightBrushKey too of course.

    The foreground resource key for inactive selections is SystemColors.InactiveSelectionHighlightTextBrushKey.

提交回复
热议问题