I have a WPF application and I need to know how to center the wain window programatically (not in XAML).
I need to be able to do this both at startup and in response
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.