我的wpf应用程序中有一个模态弹出窗口。显示该窗口后,在某些(罕见)情况下,窗口从UI中消失。但我们可以发现使用“alt + tab”并且无法激活它。
请在下面找到我使用的代码,
//WindowInteropHelper assists interoperation between Windows Presentation Foundation (WPF) and Win32 code.
private void OnControlClick(object sender, RoutedEventArgs e)
{
System.Drawing.Point p = System.Windows.Forms.Control.MousePosition;
MyPopup popup = new MyPopup();
_windowInteropHelper = new System.Windows.Interop.WindowInteropHelper(popup);
_windowInteropHelper.Owner = this._owner;
popup.WindowStartupLocation = System.Windows.WindowStartupLocation.Manual;
popup.Left = p.X;
popup.Top = p.Y;
popup.Closing += new System.ComponentModel.CancelEventHandler(OnPopupClosing);
popup.ShowDialog();
}
答案 0 :(得分:0)
尝试使用IsOpen属性来显示/隐藏弹出窗口。