Here is an improvement of @Matus' answer which eliminates the hard-coded constants. The hard-coded constants are not correct in all situations (monitor resolution, Windows versions, personalization settings).
This code answers the question about calculating the size (and position) of the maximized window. It leaves some things to be desired, but they are outside of the scope of the question:
Maximizing has been disabled, because the standard maximization covers the taskbar.
Resizing has been disabled, because if you do so, it is hard to restore it to exactly the maximized size.
The user can move the Window, causing it to be partly outside of the screen. (For this, see WPF disable window moving)
It does not take into account multiple monitors.
public partial class MainWindow : Window { public MainWindow() { InitializeComponent();
// Settings for WindowsStyle.SingleBorderWindow, ThreeDBorderWindow, ToolWindow:
WindowStyle = WindowStyle.SingleBorderWindow;
WindowState = WindowState.Normal;
ResizeMode = ResizeMode.CanMinimize; // Disallow maximizing and resizing
double differenceX = SystemParameters.MaximizedPrimaryScreenWidth - SystemParameters.WorkArea.Width;
double differenceY = SystemParameters.MaximizedPrimaryScreenHeight - SystemParameters.WorkArea.Height;
Left = -differenceX / 2;
Top = 0;
Width = SystemParameters.MaximizedPrimaryScreenWidth;
Height = SystemParameters.MaximizedPrimaryScreenHeight - differenceY / 2;
// Settings for WindowsStyle.None:
//WindowStyle = WindowStyle.None;
//WindowState = WindowState.Normal;
//Left = 0;
//Top = 0;
//Width = SystemParameters.WorkArea.Width;
//Height = SystemParameters.WorkArea.Height;
}
}