question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MetroWindow acts as though Topmost is enabled until disabled while running

See original GitHub issue

Describe 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

  1. Create new .NET Core 3.1 WPF project in Visual Studio.
  2. Add latest prerelease NuGet for MahApps.
  3. Change default MainWindow to leverage MahApps.Metro namespace and to inherit MetroWindow instead of Window.
  4. 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>
  1. Run the application and find that the window is always Topmost, system-wide.
  2. Stop application. Add an object like a ToggleSwitch and tie the IsOn attribute as follows: IsOn="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MahAppsControls:MetroWindow}}, Path=Topmost}"
  3. Restart application. Find that although the ToggleSwitch is false, the window is Topmost. Enable the ToggleSwitch, and then disable it. The window is now nolonger Topmost

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:closed
  • Created 3 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
EricLaubercommented, May 1, 2020

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?

0reactions
batzencommented, May 3, 2020

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 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

MahApps MetroWindow Topmost property Binding issue
It was a bug in ControlzEx v4.2.1. There is a Topmost hack which doesn't set the Topmost property of the Window using the...
Read more >
News
New: IsCloseButtonEnabledWithDialog property at MetroWindow which indicates if the close button should be enabled or not if a dialog is ...
Read more >
FormDesigner/MahApps.Metro.xml 4.5.2
Adds a Metro Dialog instance to the specified window and makes it visible asynchronously. If you want to wait until the user has...
Read more >
WPF Series -11- Custom MetroDialog
Today I'll show you how we implemented a custom metro dialog. Our dialog contains 2 comboboxes and gets displayed during data export to ......
Read more >
MetroWindow
The MetroWindow can be used with different borders. You can change the behavior by using the BorderBrush , GlowBrush and BorderThickness properties. Normal ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found