WPF mutli-monitor problem - WindowState

前端 未结 2 750
隐瞒了意图╮
隐瞒了意图╮ 2021-01-13 16:20

I\'ve been trying to get my WPF application to span multiple monitors for some time now and nearly have it working.

The problem seems to arise when I set the followi

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 16:42

    If you can always assume that your secondary monitor is at the same resolution as the primary, you could implement something like this:

    // Use this is you are concerned about the taskbar height
    Rect workArea = SystemParameters.WorkArea;
    this.Width = SystemParameters.PrimaryScreenWidth * 2;
    this.Height = workArea.Bottom;
    this.Left = 0;
    this.Top = 0;
    

    Or:

    // Use this is you don't care about the taskbar height
    this.Width = SystemParameters.PrimaryScreenWidth * 2;
    this.Height = SystemParameters.PrimaryScreenHeight;
    this.Left = 0;
    this.Top = 0;
    

提交回复
热议问题