1

When the HideSelection is set to false and the ListView lost focus, the selected items will be grey out. Previously, when we use ListBox, when it lost focus, the selected items are still highlighted in the active colour (i.e., blue). We changed these ListBoxes to ListViews in order to use VirtualMode to reduce the loading time, and now a lot of users complained that it is very hard for them to see which items they selected and which they did not. They want the selected items to be highlighted in a blue colour like what they had with ListBoxes previously.

May I know if there is any way to do so? I have spent 2 days to google out, but it just seems to be impossible. Thanks.

Edit 1: Someone suggested this answer: WPF ListView Inactive Selection Color but I am developing C# application and can't find a C# code in that answer.

Edit 2: Actually I asked the same question to this guy: How to change listview selected row backcolor even when focus on another control?, but the answers there are irrelevant to me. The issue is that guy only want to adjust the listview item colors when they type in textbox, so he can accept the answer about capturing textbox event and redraw it. But my case is different, there are a lot of different kinds of control that can make listview lose focus, including other listviews

Ethan
  • 11
  • 3
  • make note of all the selected items and reselect them after – BugFinder Oct 30 '17 at 08:47
  • These selected items are always selected - they are just in grey color, so there is no need to reselect them. Just refocus back to the ListView will make them highlighted in blue colour again. But the problem is if there are more than 1 ListView in a same control, it is not possible to keep all of them focus at the same time. – Ethan Oct 30 '17 at 08:53
  • Possible duplicate of [WPF ListView Inactive Selection Color](https://stackoverflow.com/questions/382006/wpf-listview-inactive-selection-color) – Manfred Radlwimmer Oct 30 '17 at 08:53
  • @Ethan i misunderstood (no caffine yet) I thought the data was refreshed. – BugFinder Oct 30 '17 at 08:55
  • @Ethan The accepted answer on that one is a bit outdated so make sure to check out the other answers as well (especially the ones with `InactiveSelectionHighlightBrushKey` and `InactiveSelectionHighlightTextBrushKey` - requires .Net 4.5+ [compatibility can be checked with this property](https://msdn.microsoft.com/en-us/library/system.windows.frameworkcompatibilitypreferences.areinactiveselectionhighlightbrushkeyssupported(v=vs.110).aspx)) – Manfred Radlwimmer Oct 30 '17 at 08:57
  • @Manfred Radlwimmer I am developing desktop application in C# instead of WPF like that answer. Is it possible to share a C# code for it? Thanks. – Ethan Oct 30 '17 at 10:20
  • What do you mean with *"C# instead of WPF"*? Do you mean WinForms? – Manfred Radlwimmer Oct 30 '17 at 10:21
  • If yes: https://stackoverflow.com/questions/3663704/how-to-change-listbox-selection-background-color – Manfred Radlwimmer Oct 30 '17 at 10:22
  • Thanks for the answer... but it doesn't work, that link is for list box, and it is not for lost-focus highlight. – Ethan Oct 30 '17 at 10:26
  • @Ethan should work the same for ListView. – Manfred Radlwimmer Oct 30 '17 at 10:28
  • Actually I asked the same question to this guy: https://stackoverflow.com/questions/5179664/how-to-change-listview-selected-row-backcolor-even-when-focus-on-another-control, but the answers there are irrelevant to me. The issue is that guy only want to adjust the listview item colors when they type in textbox, so he can accept the answer about capturing textbox event and redraw it. But my case is different, there are a lot of different kinds of control that can make listview lose focus, including other listviews. – Ethan Oct 30 '17 at 10:33

0 Answers0