未验证 提交 01547d9c 编写于 作者: V Vatsan Madhavan 提交者: GitHub

Merge pull request #2097 from wpfcontrib/contextmenu_fixup

Context Menus are sometimes not shown in High-DPI applications
......@@ -1510,7 +1510,7 @@ private void CreateWindow(bool asyncCall)
// cascading failure.
if (PopupInitialPlacementHelper.IsPerMonitorDpiScalingActive)
{
DestroyWindow();
DestroyWindowImpl();
_positionInfo = null;
makeNewWindow = true;
}
......@@ -1601,18 +1601,40 @@ private void BuildWindow(Visual targetVisual)
_secHelper.BuildWindow(origin.x, origin.y, targetVisual, IsTransparent, PopupFilterMessage, OnWindowResize, OnDpiChanged);
}
private void DestroyWindow()
/// <summary>
/// Destroys the underlying window (HWND) if it is alive
/// </summary>
/// <returns>true if the window was destroyed, otherwise false</returns>
private bool DestroyWindowImpl()
{
if (_secHelper.IsWindowAlive())
{
_secHelper.DestroyWindow(PopupFilterMessage, OnWindowResize, OnDpiChanged);
ReleasePopupCapture();
return true;
}
// Raise closed event after popup has actually closed
OnClosed(EventArgs.Empty);
return false;
}
// When closing, clear the placement target registration
UpdatePlacementTargetRegistration(PlacementTarget, null);
/// <summary>
/// Destroys the window, and does additional book-keeping
/// like releasing the capture, raising Closed event, and
/// clearing placement-target registration
/// </summary>
private void DestroyWindow()
{
if (_secHelper.IsWindowAlive())
{
if (DestroyWindowImpl())
{
ReleasePopupCapture();
// Raise closed event after popup has actually closed
OnClosed(EventArgs.Empty);
// When closing, clear the placement target registration
UpdatePlacementTargetRegistration(PlacementTarget, null);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册