How do you center your main window in WPF?

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

    You will have to find this line : Title="MainWindow" Height="450" Width="800"

    And you add this line to it : WindowStartupLocation="CenterScreen"

    To become this : Title="MainWindow" Height="450" Width="800" WindowStartupLocation="CenterScreen">

    Thank me Later ♥

    0 讨论(0)
提交回复
热议问题