2016-09-19 52 views
0

我在定位窗口时遇到了问题。窗户不是我的主窗口。我想将窗口放置在任务栏上方工作区域的右下角。通知窗口在右下角的位置

我有下面的代码:

public partial class NotificationWindow : Window 
{ 
    public NotificationWindow() 
    { 
     InitializeComponent(); 
    } 

    private void Window_Loaded(object sender, RoutedEventArgs e) 
    { 
     Rect desktopWorkingArea = SystemParameters.WorkArea; 
     Left = desktopWorkingArea.Right - Width; 
     Top = desktopWorkingArea.Bottom - Height; 
    } 
} 

及事与愿违的结果代码的:

enter image description here

我想有通知窗口在任务栏上方稍稍高出。 我认为我的代码应该可以工作,但事实并非如此。

感谢您的咨询。

+0

添加偏移或找出任务栏的大小 - https://winsharp93.wordpress.com/2009/06/29/find-out-size-and-position-of-the-taskbar/ –

回答

1

我用这个结果令人满意。

double width = 375; 
double height = 275; 

Window w = new Window(); 
w.Width = width; 
w.Height = height; 
w.Left = SystemParameters.FullPrimaryScreenWidth - width; 
w.Top = SystemParameters.FullPrimaryScreenHeight - height; 

w.ShowDialog(); 
+0

哦,它有用。谢谢! –