0

当通过 DragMove 将窗口拖动到特定区域时,我想在该区域显示半透明窗口覆盖。

显示窗口工作正常,但它总是会出现在我拖动的窗口的顶部。

在显示叠加层后,我尝试了各种方法,例如 .focus/.activate ,但它们不起作用。

每个窗口都有WindowStyle="None" Topmost="True" ShowInTaskbar="False" ,覆盖窗口甚至有IsHitTestVisible="False" Focusable="False"。不过,当它的可见性被切换时,覆盖仍然会获得焦点。

4

1 回答 1

-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;
  }
}
于 2012-10-17T21:00:40.810 回答