How can I find the position of a maximized window?

前端 未结 7 1544
走了就别回头了
走了就别回头了 2020-12-30 05:23

I need to know the position of a window that is maximized.

WPF Window has Top and Left properties that specifies the window\'s location. However, if you maximize the

相关标签:
7条回答
  • 2020-12-30 06:06

    I haven't found a solution to your problem, but if you need to position the window just to create a new one you can do the following:

    ...
    Window windowNew = new Window();
    ConfigureWindow(this, windowNew);
    Window.Show();
    ...
    
    static public void ConfigureWindow(Window windowOld, Window windowNew)
        {
            windowNew.Height = windowOld.ActualHeight;
            windowNew.Width = windowOld.ActualWidth;
    
            if (windowOld.WindowState == WindowState.Maximized)
            {
                windowNew.WindowState = WindowState.Maximized;
            }
            else
            {
                windowNew.Top = windowOld.Top;
                windowNew.Left = windowOld.Left;
            }
        }
    
    0 讨论(0)
提交回复
热议问题