How do you center your main window in WPF?

前端 未结 13 1349
爱一瞬间的悲伤
爱一瞬间的悲伤 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:35

    Go to property window of MainWindow.xaml

    • find WindowStartupLocation property from Common category
    • select CenterScreen option from dropdown
    • Run the Application

    For Full Screen

    Go to property window of MainWindow.xaml

    • find WindowState property from Common category
    • select Maximized option from dropdown
    • Run the Application

提交回复
热议问题