You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何创建覆盖所有垂直连接显示器的单个WPF全屏窗口?

问题:单WPF窗口跨多垂直显示器全屏显示失败

我有多台不同分辨率的显示器垂直连接,希望创建一个单独的WPF Window,使其在所有屏幕上最大化显示。尝试了以下代码解决方案但未生效,实际效果如下:

public MainWindow()
{
    InitializeComponent();
    this.WindowStyle = WindowStyle.None;
    this.Topmost = true;

    this.Background = System.Windows.Media.Brushes.Black;
    this.Loaded += MainWindow_Loaded;1
    Background = System.Windows.Media.Brushes.Black;
    WindowStartupLocation = WindowStartupLocation.Manual;
    this.Show();
}

private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Rectangle totalBounds = System.Windows.Forms.Screen.AllScreens
        .Select(screen => screen.Bounds)
        .Aggregate(Rectangle.Union);

    
    this.Left = totalBounds.Left;
    this.Top = totalBounds.Top;
    this.Width = totalBounds.Width;
    this.Height = totalBounds.Height;            

    var hwnd = new WindowInteropHelper(this).EnsureHandle();
    WindowsServices.SetWindowPos(hwnd, WindowsServices.HWND_TOPMOST, (int)this.Left, (int)this.Top, (int)this.Width, (int)this.Height, WindowsServices.SWP_NOACTIVATE);
}

实际效果截图

我的屏幕布局如下:

屏幕布局示意图

还尝试过一种为每个屏幕创建新窗口的方案,但不符合我单窗口覆盖所有屏幕的需求。

内容的提问来源于stack exchange,提问作者the.cicada.himself

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 09:25:22