如何创建覆盖所有垂直连接显示器的单个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
相关产品推荐
相关产品推荐

