2012-10-17 93 views
0

當通過DragMove拖動窗口到達特定區域時,我想在該區域顯示半透明窗口覆蓋圖。WPF將窗口移到前面

顯示窗口工作正常,但它總是會出現在我拖動的窗口頂部。

我嘗試了各種東西,例如.focus/.activate顯示覆蓋後,但他們沒有工作。

每個窗口都有WindowStyle="None" Topmost="True" ShowInTaskbar="False",覆蓋窗口甚至有IsHitTestVisible="False" Focusable="False"。儘管如此,當可見度被打開時,疊加仍然會得到關注。

回答

-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; 
    } 
} 
+1

隨時發佈其他解決方案,以防萬一你有更好的工作。 –