Open Symbai opened 3 years ago
@Symbai I don't know exactly why this happens, but it's maybe another issue with borderless windows using chrome. A workaround is to set the minimized state at the loaded event of the window:
using System.Windows;
using MahApps.Metro.Controls;
namespace WpfApp3
{
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
// WindowState = WindowState.Minimized;
SizeToContent = SizeToContent.Width;
this.Loaded += SizeToContentDemo_Loaded;
}
private void SizeToContentDemo_Loaded(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
}
}
Describe the bug
When setting
SizeToContent = SizeToContent.Width
andWindowState = WindowState.Minimized
in code on application start. The height is changed but it shouldn't. FYI this only happens on MetroWindow but not WPF's default Window.Environment
Reproduce
XAML
Code
Actual behavior:
Expected behavior:
Comment or remove either this:![image](https://user-images.githubusercontent.com/14368203/93192419-f4cb7500-f745-11ea-8871-b5ab606a69fc.png)
WindowState = WindowState.Minimized;
or that line:SizeToContent = SizeToContent.Width;