How to center a WPF app on screen?

前端 未结 8 937
清歌不尽
清歌不尽 2021-01-30 09:53

I want to center my WPF app on startup on the primary screen. I know I have to set myWindow.Left and myWindow.Top, but where do I get the values?

I found System.Wi

8条回答
  •  渐次进展
    2021-01-30 10:37

    Put this in your window constructor

    WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
    

    .NET FrameworkSupported in: 4, 3.5, 3.0

    .NET Framework Client ProfileSupported in: 4, 3.5 SP1

提交回复
热议问题