I\'m using the WPF Shell Integration Library to create a custom chrome of my wpf app. All is good, but when maximizing the app, 6 or 7 pixels are out of the screen.
From here, I thought I would try setting WindowChrome.NonClientFrameEdges
.
With some experimentation it turns out that you can get the desired effect by setting it to NonClientFrameEdges.Bottom
when maximised, and setting it back to NonClientFrameEdges.None
when not maximised.
This makes the margin disappear on all edges except the bottom, but crucially causes the overlap under the taskbar to no longer happen.
It is important that the WindowChrome is set prior to the WindowState, so in my code-behind I have the functions (MainGrid2 holds all the window content barring the status bar, and StatusGrid holds the status bar):
private void Maximise()
{
StatusGrid.Margin = new Thickness(7, 0, 7, 0);
MainGrid2.Margin = new Thickness(12, 12, 12, 0);
chrome.NonClientFrameEdges = NonClientFrameEdges.Bottom;
WindowChrome.SetWindowChrome(this, chrome);
WindowState = System.Windows.WindowState.Maximized;
}
private void Restore()
{
StatusGrid.Margin = new Thickness(0);
MainGrid2.Margin = new Thickness(5, 5, 5, 0);
chrome.NonClientFrameEdges = NonClientFrameEdges.None;
WindowChrome.SetWindowChrome(this, chrome);
WindowState = System.Windows.WindowState.Normal;
}