WPF でモーダル ダイアログをシミュレートするには、ウィンドウを表示して次のように呼び出します。Mouse.Capture(dialogBoxArea, CaptureMode.SubTree);
呼び出しが返されますfalse
。
Mouse.Captured
ですnull
。
dialogBoxArea.Visibility
ですVisibility.Visible
。
dialogBoxArea.IsEnabled
ですtrue
。
行がもう一度呼び出されると、戻りtrue
、マウスを正しくキャプチャします。
キャプチャが機能しない原因として、どのような条件が欠けている可能性がありますか?
編集
これが私がこれまでに試したことです。
if (Mouse.Captured != null)
{
// Not called, so presumably, nothing has already captured the mouse
MessageBox.Show("already captured");
}
if (dialogBoxArea.Visibility != Visibility.Visible)
{
// Not called
MessageBox.Show("not visible");
}
if (!dialogBoxArea.IsEnabled)
{
// Not called
MessageBox.Show("not enabled");
}
// According to documentation, this should release mouse capture from anything that holds it
Mouse.Capture(null);
// Attempt to capture the mouse
if (!Mouse.Capture(dialogBox, CaptureMode.SubTree))
{
// This is called
Mouse.Capture(null);
Mouse.Capture(dialogBox, CaptureMode.SubTree);
}