I am trying to have the SizeToContent=\"WidthAndHeight\" and WindowState = \"Maximized\" at the same time. I tried to change the state of my window during loading, as well as in
Thanks Eugene, I got the idea. I already tried to change the state of my MainWindow
at run time, but it didn't work out (MainWindow
didn't occupy the full screen).
The reason, as Eugene mentioned, is that these properties conflict with each other (SizeToContent
gets the priority) so I have to turn one off in order to be able to turn the other on. Hence, to solve the problem:
private void MainWindowMy_Loaded(object sender, RoutedEventArgs e)
{
this.SizeToContent = System.Windows.SizeToContent.Manual;
this.WindowState = System.Windows.WindowState.Maximized;
}
It's not the most elegant way of doing it, but it serves the purpose for now. However, if anybody could come up with a more elegant solution, it would be greatly appreciated.