如何制作全屏模式,而不使用以下任务栏覆盖任务栏:wpf c#

我需要在WPF应用程序中更改Windows任务栏。 为此我设置WindowStyle="None" ,这意味着禁用Windows任务栏,并使用按钮进行自定义任务栏以恢复,最小化和关闭应用程序。 现在我的问题是如果应用程序处于最大化模式,那么我无法在Windows上看到开始菜单。

我在这里找到了一个类似的问题,但是当我尝试这个代码时它没有编译。 全屏模式,但不要覆盖任务栏

如何在最大化时创建自己的任务栏并能够看到Windows开始菜单? 在xaml中是否有可以设置它的属性窗口?

你可以试试这个:

 MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth; 

在CodeProject上找到了一个可能有用的解决方案: http : //www.codeproject.com/Articles/107994/Taskbar-with-Window-Maximized-and-WindowState-to-N

 WindowStyle="None" WindowState="Maximized" ResizeMode="NoResize" 

 this.Width = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width; this.Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height; this.Left = 0; this.Top = 0; this.WindowState = WindowState.Normal; 

建议的解决方案对我有用仍然需要更正窗口的像素到dpi setter值,无论用户设置如何都具有正确的大小:

在xaml中:

 WindowStyle="None" WindowState="Maximized" ResizeMode="NoResize" 

在代码中:

 public MainWindow() { InitializeComponent(); var graphics = System.Drawing.Graphics.FromHwnd(IntPtr.Zero); var pixelWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width ; var pixelHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height; var pixelToDPI = 96.0 / graphics.DpiX ; this.Width = pixelWidth * pixelToDPI; this.Height = pixelHeight * pixelToDPI; this.Left = 0; this.Top = 0; this.WindowState = WindowState.Normal; } 
 WindowStyle="None" AllowsTransparency="True" 

 this.Top = 0; this.Left = 0; this.Width = SystemParameters.WorkArea.Width; this.Height = SystemParameters.WorkArea.Height; 

WPF的解决方案

假设我们希望将WPF项目的mainWindow放在屏幕的右下角,而不覆盖taskBar。 我们写这个:

 public MainWindow() { InitializeComponent(); // set position of window on screen this.Left = SystemParameters.PrimaryScreenWidth - this.Width; this.Top = SystemParameters.WorkArea.Bottom - this.Height; } 

this =我们的对象(MainWindow)当我们从PrimarySrceenWidth中减去窗口位置(左)时,我们首先得到左参数。 然而,我们通过从屏幕底部的工作区域减去窗口高度来获得最低点。 屏幕的工作区域不包括任务栏!

请享用!

Avri