I'm currently working on a WPF application and I don't find how to make my application in full screen. I am using MahApps.Metro so my mainwindow's type is Controls.MetroWindow.
I tried this :
<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"
ResizeMode="NoResize"
WindowState="Maximized"
Title="MyProject">
But it doesn't hide the Windows taskbar. But it works when I use a simple Window. I looked at the MetroWindow source code, it inherits the Window class, so I don't understand why it's not working.
The only way I found to have a full screen window with Metro, is to set the IgnoreTaskbarOnMaximize propery to true and remove the ResizeMode="NoResize" (see code below), run the app and maximize it.
<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">
But I would like to hide the Minimize and Maximize button.. Have you got any ideas to start a Controls.MetroWindow in full screen ?
Currently, the only way I know how to fullscreen my wpf application is: WindowStyle=None and WindowState=Maximized (and Topmost=True, though this is just needed to make sure it's above everything else).
MahApps. Metro is a framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort, supporting .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With