How can I make a WPF window maximized on the screen with the mouse cursor?

You can set it in XAML

<Window Height="300" Width="300" WindowState="Maximized">
</Window>

You need to set SizeToContent to Manual. See other answers for details.


I asked the same question on the MSDN WPF Forum and got an answer with this awesome workaround:

void button_Click(object sender, RoutedEventArgs e)
{
    Window window = new Window();
    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
    window.SourceInitialized += (s, a) => window.WindowState = WindowState.Maximized;
    window.Show();
}

I've also submitted a bug report about this issue to Microsoft that they are currently reviewing.


Starting with the window maximize can be achieved by the following addition to the XAML markup.

<Window Height="300" Width="300" 
  WindowState="Maximized"
  SizeToContent="Manual">
</Window>

The property WindowState is subordinate to SizeToContent, which means that you need to set the latter Manual (if you wish the actual maximization). You can also set SizeToContent to Height or Width (if you wish to maximize the window in one dimension, whereas obeying the size computed based on the controls' sizes in the other).

<Window Height="300" Width="300" 
  WindowState="Maximized"
  SizeToContent="Width">
</Window>

The above will make the window span from top to bottom but not necessarily from left to right edge. It's equivalent to pressing the key combination Win+Shift+Up.


Make sure that SizeToContent is set to SizeToContent.Manual, otherwise it won't work.