WPFアプリケーションに奇妙なバグを発見しました。適切な会社に報告できるように、それがWPFまたはグラフィックスドライバーの問題であるかどうかを判断しようとしています。.NET 3.5SP1アプリケーションを実行しているWindowsXPシステムに最新のドライバー(197.54)を搭載したQuadroFX1700があります。
デュアルモニターがあり、プライマリが左側に、セカンダリが右側にあります。この問題は、プライマリモニターのメインウィンドウの子ウィンドウを最大化してから復元すると発生します。子ウィンドウのサイズはプライマリモニターで正しく設定されていますが、セカンダリモニターでは、最大化されているかのように描画されます。プライマリモニターで子ウィンドウを移動すると、セカンダリモニターでも子ウィンドウが移動します。
この動作を引き起こすサンプルアプリケーション(コードは以下)を作成しました。
- アプリケーションを起動し、メインウィンドウがプライマリモニターに表示されていることを確認します。
- メインウィンドウをダブルクリックします。緑色の子ウィンドウが表示されます。
- 緑色の子ウィンドウをクリックして最大化します。
- 緑色の子ウィンドウをクリックして復元します。
他の誰かがこの問題を再現できますか?私のシステムでは、緑色の子が復元されますが、プライマリモニターだけでなく、プライマリモニターとセカンダリモニターの両方に描画されます。
App.xaml
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DualMonitorBug.App"
StartupUri="Shell.xaml" />
App.xaml.cs
using System.Windows;
namespace DualMonitorBug { public partial class App : Application { } }
Shell.xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DualMonitorBug.Shell"
Title="Shell" Height="480" Width="640"
MouseDoubleClick="ShowDialog" />
Shell.xaml.cs
using System.Windows;
using System.Windows.Input;
namespace DualMonitorBug
{
public partial class Shell : Window
{
public Shell()
{
InitializeComponent();
}
private void ShowDialog(object sender, MouseButtonEventArgs e)
{
DialogWindow dialog = new DialogWindow();
dialog.Owner = this;
dialog.Show();
}
}
}
DialogWindow.xaml
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DualMonitorBug.DialogWindow"
Title="Dialog Window" Height="240" Width="320"
AllowsTransparency="True"
Background="Green"
MouseLeftButtonDown="ShowHideDialog"
WindowStyle="None" />
DialogWindow.xaml.cs
using System.Windows;
using System.Windows.Input;
namespace DualMonitorBug
{
public partial class DialogWindow : Window
{
public DialogWindow() { InitializeComponent(); }
private void ShowHideDialog(object sender, MouseButtonEventArgs e)
{
if (e.ClickCount == 1)
{
if (this.WindowState == WindowState.Normal)
{
this.DragMove();
}
}
else
{
this.WindowState
= (this.WindowState == WindowState.Normal)
? WindowState.Maximized
: WindowState.Normal;
}
}
}
}