How do you center your main window in WPF?

前端 未结 13 1375
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 07:07

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

13条回答
  •  猫巷女王i
    2020-11-28 07:39

    Isn't it just as simple to set

    WindowStartupLocation="CenterScreen"
    

    In the XAML definition for the window.

提交回复
热议问题