WPF – Custom Style List Box – How to preserve the style of the selected item?

I have a styled list box. List box items change color when hovering and when selected. Hovering and selecting works normally. But when you select an item and then move the mouse away Then hovering it over it will cause it to return to the hover/unselected state, even if it is still selected. How to keep the listboxitem in the “selected” visual state?





< /div>

What happened is that your states (selected and immigration) from different state groups compete for the same property (the background of myBorders). You will have to add another element (probably Is a rectangle) and change the element background in one of the states.

Generally, you should not manipulate the same attributes of the same element from states in different state groups. The visual state manager doesn’t know how Handle this situation because it doesn’t know which state should take precedence.

I have a styled list box. List box items change color when hovering and when selected .Hovering and selecting works fine. But when selecting an item and then moving the mouse away and then hovering it over it will cause it to return to the hover/unselected state, even if it is still selected. How to keep the listboxitem In the “selected” visual state?





Happened What’s the matter is that your states (selected and immigrants) from different state groups compete for the same property (the background of myBorders). You will have to add another element (probably a rectangle) and change the element background in one of the states.

Generally, you should not manipulate the same attributes of the same element from states in different state groups. The visual state manager does not know how to handle this situation because it does not know which state should take precedence .

Leave a Comment

Your email address will not be published.