设置窗口警报的位置

时间:2014-09-29 09:11:56

标签: c# wpf visual-studio-2010 alert

这里我举报一个警报示例:

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();
                });
    }

1 个答案:

答案 0 :(得分:0)

您可以在 SystemParameters 中使用一些有用的信息来正确找到窗口。具体而言,您需要获得SystemParameters.WorkArea.Bottom。代码应该是这样的:

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