Maximize WPF Window on the current screen

后端 未结 10 672
谎友^
谎友^ 2021-01-31 07:35

I have a windowless wpf application, whenever I set the window state as maximized it maximizes it on the primary display.

What I would like to do is have it maximize on

10条回答
  •  囚心锁ツ
    2021-01-31 08:26

    I am not sure if this is answered yet- I created a sample app with the

    WindowStyle = WindowStyle.None;
    

    I created a button and on the click handler did this-

    WindowState = WindowState.Maximized
    

    I hooked up the MouseLeftButtonDown handler for the window to drag move-

    this.MouseLeftButtonDown += new(MainWindow_MouseLeftButtonDown);
    
    private void MainWindow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
       DragMove();
    }
    

    When I dragged my window to my second monitor and clicked the maximize button, it maximized in the current window, not the startup window. I was using VS2010 and .NET 4. Let me know if this helps.

提交回复
热议问题