-1

我可以从 System.Windows.SystemParameters 获取虚拟屏幕大小,但由于 WPF 不能以像素为单位工作,但在 DPI 单位中我不能直接使用它。如何让我的 WPF 窗口(Border=none)完全覆盖整个虚拟屏幕?

4

1 回答 1

1

我这样做了,效果很好:

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;
}
于 2012-04-23T20:25:06.977 回答