Wpf start in primary screen

前端 未结 5 1291
臣服心动
臣服心动 2020-12-21 00:43

If user has multiple screens,

how can I start application in primary screen or chosen screen at start up

5条回答
  •  庸人自扰
    2020-12-21 01:28

    This is my borderless window implementation. You should be able to interpret this if you need any differences. I make the window 1/2 the size of my primary monitor then center it. Make sure WindowStartupLocation is set to Manual.

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        Width = SystemParameters.PrimaryScreenWidth / 2;
        Height = SystemParameters.PrimaryScreenHeight / 2;
        Left = (SystemParameters.PrimaryScreenWidth - Width) / 2;
        Top = (SystemParameters.PrimaryScreenHeight - Height) / 2;
    }
    

提交回复
热议问题