How to make full-screen mode without closing the taskbar using: wpf C #

I need to change the windows taskbar in my WPF application. To do this, I set WindowStyle="None" , which means to disable the Windows taskbar and create a custom taskbar with buttons to restore, minimize and close the application. Now my problem is that the application runs in maximization mode, then I do not see the start menu in the windows.

I found a similar question here, but when I tried this code, it did not compile. full screen mode, but do not close the taskbar

How can I create my own taskbar and see the Windows startup menu when I maximize it? Is there a properties window in xaml that can set it?

+8
c # wpf xaml taskbar
source share
6 answers

You can try the following:

 MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight; MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth; 
+17
source share

Found a solution in CodeProject that can help: http://www.codeproject.com/Articles/107994/Taskbar-with-Window-Maximized-and-WindowState-to-N

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

and

 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; 
+3
source share

The proposed solution for me was , but still need to adjust the pixel in inch settings for the window to have the correct size regardless of user settings:

in xaml:

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

in code:

 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; } 
+1
source share
 WindowStyle="None" AllowsTransparency="True" 

and

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

Solution for WPF

Suppose we want to place the main WPF project window in the lower right corner of the screen without closing the taskbar. We will write this:

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

this = our object (MainWindow) First we put the left parameter when we subtract the position of our window (left) from PrimarySrceenWidth. Then we do the same to get the lowest point, subtracting the height of the windows from the working area of ​​the bottom of the screen. The working area of ​​the screen does not include the taskbar!

enjoy!

Avri

0
source share

Some improvements in @Nicolas answer. The following code also works for multiple screens and various positioning of the taskbar.

 public MainWindow() { InitializeComponent(); var graphics = Graphics.FromHwnd(IntPtr.Zero); var pixelToDpiX = 96.0 / graphics.DpiX; var pixelToDpiY = 96.0 / graphics.DpiY; var screen = Screen.AllScreens[0]; Topmost = true; ResizeMode = ResizeMode.NoResize; Width = screen.WorkingArea.Width * pixelToDpiX; Height = screen.WorkingArea.Height * pixelToDpiY; Top = screen.WorkingArea.Top * pixelToDpiY; Left = screen.WorkingArea.Left * pixelToDpiX; WindowState = WindowState.Normal; WindowStyle = WindowStyle.None; } 
0
source share

All Articles