我在定位窗口方面遇到了问题。窗口不是我的主窗口。我想将窗口定位在任务栏上方工作区域的右下角。
我有以下代码:
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;
}
}
该代码不需要的结果:
我想让通知窗口高出任务栏。 我认为我的代码应该可行,但事实并非如此。
感谢您的建议。
答案 0 :(得分: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();