当拖动窗口时,如果它通过DragMove进入特定区域,我想在该区域显示一个半透明的窗口覆盖。
显示窗口工作正常,但它总是会出现在我拖动的窗口顶部。
在我显示叠加后,我尝试了各种各样的东西,例如.focus / .activate,但它们没有用。
每个窗口都有WindowStyle="None" Topmost="True" ShowInTaskbar="False"
,覆盖窗口甚至有IsHitTestVisible="False" Focusable="False"
。但是,当它的可见性被切换时,叠加仍然会得到焦点。
答案 0 :(得分:-1)
我发现工作的唯一方法是隐藏我的主窗口然后再显示它。虽然,我不希望它闪烁,所以当我这样做时我禁用了调度员。这最终工作得很漂亮。我在网上找不到任何类似的问题所以我想我会发布这个以帮助下一个人。
private void showOverlay()
{
//show the docking window
_overlayWindow.Visibility = Visibility.Visible;
//problem here will be that the overlay window will be on top of main
//this.focus this.activate +other efforts did not work to bring main back on top
//only thing i could find that would bring the main win on top is to hide/show it again.
//i wrap this hide/show in a disabled dispatcher block so that the window never really gets hidden on screen
using (var d = Dispatcher.DisableProcessing())
{
this.Visibility = Visibility.Hidden;
this.Visibility = Visibility.Visible;
}
}