设置位置
在这里我报告我的警觉的例子:设置位置
正如你可以从图片中看到我不能让任务栏上面我的警告窗口。
这是我设置窗口的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();
});
}
你可以使用一些有用的信息在SystemParameters以正确定位的窗口。具体而言,您需要获得SystemParameters.WorkArea.Bottom
。代码应该是这样的:
this.Left = SystemParameters.WorkArea.Right - this.ActualWidth;
this.Top = SystemParameters.WorkArea.Bottom - this.ActualHeight;
以这种方式,我的警报窗口降到屏幕下方。 我有这样的事情:[链接](http://oi61.tinypic.com/5kghv6.jpg) – iamwill 2014-09-29 13:37:17
@iamwill我已经用这个为我的一些项目。我猜***任务栏***会自动隐藏? (只有当您将鼠标移动到屏幕的底部时才显示它?)。如果它是固定的,我不认为偏移量如此之大。 – 2014-09-29 14:56:12
也请使用我贴的代码。从你的图像中,我可以看到窗口的“Top”正好在WorkArea的“底部”,这意味着'ActualHeight'是** 0 **?这没有什么意义。事实上,可能会有一些抵消,但它应该很小(从我的经验)。 – 2014-09-29 15:01:09
在您的屏幕截图中,警报位于任务栏上方。这里有什么问题? – Herdo 2014-09-29 09:19:43
警报必须略高于最左侧。 – iamwill 2014-09-29 09:36:29
@Herdo在Y轴上可能是“上方”(即op希望它不*重叠任务栏),但我只是猜测 – Alex 2014-09-29 09:42:29