マルチモニター システムに問題があり、ボーダレス WPF C# .NET 4.0 ウィンドウを最大化しています。1 台のモニターは 1680x1050 (プライマリ) で、2 台目は 1920x1080 (セカンダリ) です。プライマリ画面でウィンドウを最大化しているとき - これら 2 つの順序を入れ替えても問題ありません。しかし、セカンダリ画面で最大化しようとするたびに、プライマリモニターのサイズに切り詰められています。ウィンドウサイズが適切に指定されていることがわかりますが、これは機能しません。
モニターのサイズを取得する:
private System.Windows.Forms.Screen GetCurrentScreen()
{
System.Drawing.Point centerPoint = new System.Drawing.Point((int)(Left + Width / 2), (int)(Top + Height / 2));
foreach (System.Windows.Forms.Screen s in System.Windows.Forms.Screen.AllScreens)
{
if (s.Bounds.Contains(centerPoint))
{
return s;
}
}
return null;
}
最大化:
private void Maximize
{
if (this.WindowState == WindowState.Normal)
{
var scr = GetCurrentScreen();
//this.MaxHeight = scr.WorkingArea.Height;
//this.MaxWidth = scr.WorkingArea.Width;
if (scr != null)
{
if (scr.Primary)
{
this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
this.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth;
}
else
{
this.MaxHeight = double.PositiveInfinity; //even ridiculous values don't work
this.MaxWidth = double.PositiveInfinity;
this.Height = scr.WorkingArea.Height; // correct values of 2nd screen
this.Width = scr.WorkingArea.Width;
}
}
else
{
this.MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
this.MaxWidth = SystemParameters.MaximizedPrimaryScreenWidth;
}
this.WindowState = WindowState.Maximized;
}
私が得るものは: http://imgur.com/ZYzVV9Q,yf7lSfY#1
私が欲しいもの: http://imgur.com/ZYzVV9Q,yf7lSfY#0
ありがとう