Window content remains highlighted after mouse leaves window
See original GitHub issueDescribe the bug
When opened as a modal window/dialog, the “elements” and contents of a MetroWindow
keep their highlighted mouseover appearance when the mouse cursor leaves the window. This happens only if the mouse cursor “lands” on an other application window in the background, but not if the new destination is unoccupied (see attached animations for more clarity)!
I first noticed this with the regular window minimize/maximize/close buttons - but I can observe the same behavior with a regular button within the window content area (the margin to the window border needs to be reasonably small and you have to move the mouse cursor a little bit speedy), so I dare to guess that it happens with any kind of controls.
The problem only appears if the window is opened as a dialog (Window.ShowDialog()
), but not if opened as a regular window (Window.Show()
)
To Reproduce Steps to reproduce the behavior:
- Implement two regular
MetroWindow
s (let’s name them “MainWindow” and “Window1”) - Add a
Button
to the main window and open Window1 as a modal window/dialog on theClick
event of the button:
private void Button_Click(object sender, RoutedEventArgs e)
{
Window1 window1 = new Window1();
window1.Owner = this;
window1.ShowDialog();
}
- Run the code and click the button on the main window.
- Move and resize Window1 so that it overlaps the main window.
- Hover the mouse over the close button of Window1 and observe its highlighted appearance.
- Quickly move the mouse cursor off the close button and onto the main window in the background.
- The close button of Window1 remains highlighted until the mouse cursor enters Window1 again (not necessarily via its close button, just anywhere)
Expected behavior All window elements and contents return to their regular, non-highlighted appearance after the mouse cursor has left the window.
Screenshots
- Moving mouse to unoccupied area: No issue
- Moving mouse to area occupied by other application window: Unexpected behavior
Environment(please complete the following information):
- MahApps.Metro version v1.6.5
- OS: Win10
- Visual Studio 2017 15.9.11
- .NET Framework 4.6.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (2 by maintainers)
I have a similar problem. And I found that if I didn’t set the “GlowBrush” of the main window, everything would be ok. The GlowBrush is from ControlzEx.
I haven’t found a solution yet. I hope I can provide you with ideas. Problem will occur in MahApp version is 2.0+
@punker76 Thanks for pointing out that the issue also happens without MahApps.Metro! A two-minute Google search (facepalm) revealed this is a known issue with borderless windows (which, I believe, MahApps.Metro.MetroWindow is…)
Have a look here!
Maybe this solution can be incorporated into a future release of MahApps.Metro? 🤔