MetroWindow acts as though Topmost is enabled until disabled while running
See original GitHub issueDescribe the bug
All of the MetroWindow
objects in my application are acting as though I’ve set Topmost = true
when I haven’t. Explicitly configuring Topmost = false
in XAML or as part of a DataContext does not change this - but copying the logic from MenuItem
logic from the most recent develop
branch example does fix it.
To Reproduce
- Create new .NET Core 3.1 WPF project in Visual Studio.
- Add latest prerelease NuGet for MahApps.
- Change default
MainWindow
to leverageMahApps.Metro
namespace and to inheritMetroWindow
instead ofWindow
. - Add the following to
App.xaml
:
<ResourceDictionary.MergedDictionaries>
<!-- MahApps -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
</ResourceDictionary.MergedDictionaries>
- Run the application and find that the window is always
Topmost
, system-wide. - Stop application. Add an object like a
ToggleSwitch
and tie theIsOn
attribute as follows:IsOn="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MahAppsControls:MetroWindow}}, Path=Topmost}"
- Restart application. Find that although the
ToggleSwitch
isfalse
, the window isTopmost
. Enable theToggleSwitch
, and then disable it. The window is now nolongerTopmost
I have found you can replace the last steps with the Visual Studio debugger by viewing the properties of the MetroWindow
. If I forcefully enable Topmost
and then disable it, the window well then act as though Topmost
is disabled.
I have also found this occurs for not just my MainWindow
but any other MetroWindow
I add to the application.
Expected behavior
I expect MetroWindow
objects to default to Topmost = false
, and I expect that if I explicitly configure this in the XAML that the MetroWindow
will respond to this configuration.
Environment:
- MahApps.Metro 2.0.0-alpha0775
- OS: Windows 10 Pro 1909 18363.778
- Visual Studio 2019 16.4.3
- .NET Core 3.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (5 by maintainers)
It’s 4.3.0-alpha0085 Okay. Thank you for the help - I have found my issue. It has nothing to do with MahApps. I began removing code to prepare to upload a copy and upon removing a section I believed to be unrelated, the
Topmost
behavior began working correctly. I’m not sure why this is, but it’s clearly something I did and not part of the library.Do you have any special procedure for closing issues or otherwise removing them?
That’s interesting as normally your window should get closed when you close it’s owner. Having a topmost owner seems to break this behavior. May i say that making a splash screen topmost is not nice application behavior? It always annoys me when applications do that 😉