I basically want to have my WPF window to go in full screen mode, when F11 is pressed or the maximize button in the right top corner of the window is pressed.
While the
I have found easy way to achieve fullscreen in WPF:
private double LastHeight, LastWidth;
private System.Windows.WindowState LastState;
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F11)
{
if (WindowStyle != WindowStyle.None)
{
LastHeight = Height;
LastWidth = Width;
LastState = WindowState;
Topmost = true;
Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
Top = 0;
Left = 0;
WindowState = System.Windows.WindowState.Normal;
WindowStyle = WindowStyle.None;
ResizeMode = System.Windows.ResizeMode.NoResize;
}
else
{
WindowStyle = WindowStyle.SingleBorderWindow;
WindowState = LastState; ;
ResizeMode = ResizeMode.CanResizeWithGrip;
Topmost = false;
Width = LastWidth;
Height = LastHeight;
}
}
}
This works good in Windows 7 with fixed Taskbar.