Going fullscreen on secondary monitor

前端 未结 7 1640
离开以前
离开以前 2020-11-30 02:31

How can you program a dotNet Windows (or WPF) Application in order to let it going fullscreen on the secondary monitor?

7条回答
  •  一向
    一向 (楼主)
    2020-11-30 02:57

    I notice an answer which advocates setting the position in the Loaded event, but this causes flicker when the window is first shown normal then maximized. If you subscribe to the SourceInitialized event in your constructor and set the position in there it will handle maximizing onto secondary monitors without flicker - I'm assuming WPF here

    public MyWindow()
    {
        SourceInitialized += MyWindow_SourceInitialized;
    }
    
    void MyWindow_SourceInitialized(object sender, EventArgs e)
    {
        Left = 100;
        Top = 50;
        Width = 800;
        Height = 600;
        WindowState = WindowState.Maximized;
    }
    

    Substitute coords for any on your secondary monitor

提交回复
热议问题