How do you center your main window in WPF?

前端 未结 13 1352
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 07:39

    In the window element just add this attribute-value pair: WindowStartupLocation="CenterScreen"

提交回复
热议问题