【发布时间】:2012-04-23 20:20:26
【问题描述】:
我可以从 System.Windows.SystemParameters 获取虚拟屏幕大小,但由于 WPF 不能以像素为单位工作,但在 DPI 单位中我不能直接使用它。 如何让我的 WPF 窗口 (Border=none) 完全覆盖整个虚拟屏幕?
【问题讨论】:
-
你能展示你目前拥有的代码吗(例如获取虚拟屏幕大小的代码等)?
我可以从 System.Windows.SystemParameters 获取虚拟屏幕大小,但由于 WPF 不能以像素为单位工作,但在 DPI 单位中我不能直接使用它。 如何让我的 WPF 窗口 (Border=none) 完全覆盖整个虚拟屏幕?
【问题讨论】:
我这样做了,效果很好:
public MainWindow()
{
InitializeComponent();
this.WindowStyle = System.Windows.WindowStyle.None;
this.Height = SystemParameters.VirtualScreenHeight;
this.Width = SystemParameters.VirtualScreenWidth;
this.Left = 0;
this.Top = 0;
}
这是您的想法(但没有发布)吗?
private void Window_Loaded(object sender, RoutedEventArgs e)
{
this.WindowStyle = System.Windows.WindowStyle.None;
this.Left = 0;
this.Top = 0;
Point screenPoint = new Point(SystemParameters.VirtualScreenWidth, SystemParameters.VirtualScreenHeight);
Point translatedPoint = this.PointFromScreen(screenPoint);
this.Height = translatedPoint.Y;
this.Width = translatedPoint.X;
}
【讨论】: