How to center a WPF app on screen? Ask Question

How to center a WPF app on screen? Ask Question

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.Windows.Forms.Screen.PrimaryScreen, which is apparently not WPF. Is there a WPF alternative that gives me the screen resolution or something like that?

ベストアンサー1

xaml

<Window ... WindowStartupLocation="CenterScreen">...

おすすめ記事