Make WPF Application Fullscreen (Cover startmenu)

前端 未结 6 724
故里飘歌
故里飘歌 2020-12-23 13:12

I would like to make my WPF application fullscreen. Right now the start menu prevents it from covering everything and shifts my application up. This is what I have for my Ma

相关标签:
6条回答
  • 2020-12-23 13:43

    You can also do it at run time as follows :

    • Assign name to the window (x:Name = "HomePage")
    • In constructor just set WindowState property to Maximized as follows

    HomePage.WindowState = WindowState.Maximized;

    0 讨论(0)
  • 2020-12-23 13:44

    You're probably missing the WindowState="Maximized", try the following:

    <Window x:Class="HTA.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        WindowStyle="None" ResizeMode="NoResize"  
        WindowStartupLocation="CenterScreen" WindowState="Maximized">
    
    0 讨论(0)
  • 2020-12-23 13:54
    <Window x:Class="HTA.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        mc:Ignorable="d" 
        ResizeMode="NoResize"
        WindowStartupLocation="CenterScreen" 
        Width="1024" Height="768"
        WindowState="Maximized" WindowStyle="None">
    

    Window state to Maximized and window style to None

    0 讨论(0)
  • 2020-12-23 13:54
    window.WindowStyle = WindowStyle.None;
    window.ResizeMode = ResizeMode.NoResize;
    window.Left = 0;
    window.Top = 0;
    window.Width = SystemParameters.VirtualScreenWidth;
    window.Height = SystemParameters.VirtualScreenHeight;
    window.Topmost = true;
    

    Works with multiple screens

    0 讨论(0)
  • If you want user to change between WindowStyle.SingleBorderWindow and WindowStyle.None at runtime you can bring this at code behind:

    Make application fullscreen:

    RootWindow.Visibility = Visibility.Collapsed;
    RootWindow.WindowStyle = WindowStyle.None;
    RootWindow.ResizeMode = ResizeMode.NoResize;
    RootWindow.WindowState = WindowState.Maximized;
    RootWindow.Topmost = true;
    RootWindow.Visibility = Visibility.Visible;
    

    Return to single border style:

    RootWindow.WindowStyle = WindowStyle.SingleBorderWindow;
    RootWindow.ResizeMode = ResizeMode.CanResize;
    RootWindow.Topmost = false;
    

    Note that without RootWindow.Visibility property your window will not cover start menu, however you can skip this step if you making application fullscreen once at startup.

    0 讨论(0)
  • 2020-12-23 13:57

    When you're doing it by code the trick is to call

    WindowStyle = WindowStyle.None;
    

    first and then

    WindowState = WindowState.Maximized;
    

    to get it to display over the Taskbar.

    0 讨论(0)
提交回复
热议问题