使WPF应用程序全屏(封面启动菜单)

我想使我的WPF应用程序全屏。 现在开始菜单阻止它覆盖所有内容,并将我的应用程序转移。 这是我的MainWindow.xaml代码:

<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" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Width="1024" Height="768"> 

您可能错过了WindowState="Maximized" ,请尝试以下操作:

 <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"> 
 <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"> 

窗口状态为最大化,窗口样式为无

您也可以在运行时按照以下步骤进行操作:

  • 为窗口指定名称(x:Name =“HomePage”)
  • 在构造函数中,将WindowState属性设置为Maximized,如下所示

HomePage.WindowState = WindowState.Maximized;

 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; 

适用于多个屏幕