C# 设置windows警报的位置
在此,我报告一个警报示例: 正如您从图片中看到的,我无法将警报窗口置于任务栏上方 这是我设置窗口位置的代码:C# 设置windows警报的位置,c#,wpf,visual-studio-2010,alert,C#,Wpf,Visual Studio 2010,Alert,在此,我报告一个警报示例: 正如您从图片中看到的,我无法将警报窗口置于任务栏上方 这是我设置窗口位置的代码: public new void Show() { this.Left = Application.Current.MainWindow.Left + Application.Current.MainWindow.ActualWidth - this.Width; this.Top = Application.Current
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();
});
}
您可以使用中的一些有用信息来正确定位窗口。具体来说,您需要获取SystemParameters.WorkArea.Bottom。代码应如下所示:
this.Left = SystemParameters.WorkArea.Right - this.ActualWidth;
this.Top = SystemParameters.WorkArea.Bottom - this.ActualHeight;
在屏幕截图中,警报位于任务栏上方。这里有什么问题?警报必须在最左边和最上面。@Herdo上面的意思可能是在Y轴上,即op希望它不与任务栏重叠,但我只是猜测Alex的确切位置。我不希望重叠,但沿Y轴高于平均值。对不起,我的英语学得不好。那么,在方法展示中这是什么呢?新窗口通常会从左上角产生一个小偏移量。这样,我的警报窗口就会下降到屏幕下方。我有这样的想法:@iamwill我在我的一些项目中使用过这个。我猜任务栏是自动隐藏的?当您在屏幕底部边缘移动鼠标时,屏幕上会显示该图标?。如果它是固定的,我不认为偏移量这么大。也请使用我发布的代码。从您的图像中,我可以看到窗口的顶部正好位于工作区的底部,这意味着实际高度为0?这没有多大意义。事实上,可能有一些抵消,但它应该是小从我的经验。完美!!!谢谢国王!!!已自动覆盖偏移量我输入您的代码时出错