WPF Metro Window full screen

本秂侑毒 提交于 2019-12-03 02:57:54

I can reproduce your issue. You should report it as a bug Here

Simple workaround for now could be:

Keep your xaml the same as you got to:

<Controls:MetroWindow x:Class="MyProject.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                      xmlns:Views="clr-namespace:MyProject.Views"
                      WindowStyle="None"
                      IgnoreTaskbarOnMaximize="True"
                      Title="MyProject">

and in the Window's code-behind:

public MainWindow() {
  InitializeComponent();
  Loaded += OnLoaded;
}

private void OnLoaded(object sender, RoutedEventArgs routedEventArgs) {
  WindowState = WindowState.Maximized;
  ResizeMode = ResizeMode.NoResize;
  ShowMaxRestoreButton = false;
  ShowMinButton = false;
  Loaded -= OnLoaded;
}

This will give you the behavior you want. We pretty much set the state(maximized), hide min/max buttons with the Loaded event and only do it once.

with the latest alpha version you have two different ways to get this:

first

<Controls:MetroWindow x:Class="MyProject.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                      xmlns:Views="clr-namespace:MyProject.Views"
                      ResizeMode="NoResize"
                      WindowState="Maximized"
                      IgnoreTaskbarOnMaximize="True"
                      Title="MyProject">

second

<Controls:MetroWindow x:Class="MyProject.MainWindow"
                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                      xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                      xmlns:Views="clr-namespace:MyProject.Views"
                      UseNoneWindowStyle="True"
                      WindowState="Maximized"
                      Title="MyProject">

with the second solution you have also no titlebar, no min, max, close buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!