How can I style WPF DataGrid to change the color of selected row when DataGrid lost its focus?
相关问题
- VNC control for WPF application
- WPF Binding from System.Windows.SystemParameters.P
- XAML: Applying styles to nested controls
- How can I add a horizontal line (“goal line”) for
- How to properly change a resource dictionary
LATE ANSWER:
This works in .Net 4.0, and you don't have to hardcode the color:
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.
For .net Framework 4.0
https://social.msdn.microsoft.com/Forums/vstudio/en-US/635642e6-4808-4b3e-8aea-c8c434397d0f/datagrid-lost-focus-brush?forum=wpf
Do it like this: