The WPF window is maximized, the window is not close to the screen, and there is always a margin. What's going on?

when I make a WPF window, for some reason, I have to manually control the Maxheight of the window. When I set the MaxHeight of the window, click the maximize button, the window has maximized action, but not very close to the screen, there is always a blank of 3-5 pixels. As shown in the following figure:

if you remove the code that manually sets the window Maxheight, the window will snap to the screen normally when the window is maximized.

I would like to ask you how to solve this problem

May.12,2021

  1. you can try setting MaxHeight dynamically
  2. debug the UI, to see where the height and width of the maximized window differ from the values on the system screen.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31451-2bd74.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31451-2bd74.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?