How do you center your main window in WPF?

Well, for startup time, you can set the startup location:

window.WindowStartupLocation = WindowStartupLocation.CenterScreen;

Later, you’ll need to query it. The information (at least for the primary screen) is available via SystemParameters.PrimaryScreenWidth/Height.

Leave a Comment