2014-09-29 183 views
0

在這裏我報告我的警覺的例子:設置位置

http://oi60.tinypic.com/4lt8d2.jpg

正如你可以從圖片中看到我不能讓任務欄上面我的警告窗口。

這是我設置窗口的poszione代碼:

public new void Show() 
    { 
     this.Left = Application.Current.MainWindow.Left + 
      Application.Current.MainWindow.ActualWidth - this.Width; 
     this.Top = Application.Current.MainWindow.Top + 
      Application.Current.MainWindow.ActualHeight - this.Height; 

     this.Topmost = true; 

     Application.Current.MainWindow.Dispatcher.BeginInvoke(
      System.Windows.Threading.DispatcherPriority.ApplicationIdle, 
       (System.Threading.ThreadStart)delegate() 
       { 
        base.Show(); 
       }); 
    } 
+0

在您的屏幕截圖中,警報位於任務欄上方。這裏有什麼問題? – Herdo 2014-09-29 09:19:43

+0

警報必須略高於最左側。 – iamwill 2014-09-29 09:36:29

+0

@Herdo在Y軸上可能是「上方」(即op希望它不*重疊任務欄),但我只是猜測 – Alex 2014-09-29 09:42:29

回答

0

你可以使用一些有用的信息在SystemParameters以正確定位的窗口。具體而言,您需要獲得SystemParameters.WorkArea.Bottom。代碼應該是這樣的:

this.Left = SystemParameters.WorkArea.Right - this.ActualWidth; 
this.Top = SystemParameters.WorkArea.Bottom - this.ActualHeight; 
+0

以這種方式,我的警報窗口降到屏幕下方。 我有這樣的事情:[鏈接](http://oi61.tinypic.com/5kghv6.jpg) – iamwill 2014-09-29 13:37:17

+0

@iamwill我已經用這個爲我的一些項目。我猜***任務欄***會自動隱藏? (只有當您將鼠標移動到屏幕的底部時才顯示它?)。如果它是固定的,我不認爲偏移量如此之大。 – 2014-09-29 14:56:12

+0

也請使用我貼的代碼。從你的圖像中,我可以看到窗口的「Top」正好在WorkArea的「底部」,這意味着'ActualHeight'是** 0 **?這沒有什麼意義。事實上,可能會有一些抵消,但它應該很小(從我的經驗)。 – 2014-09-29 15:01:09