gpt4 book ai didi

c# - WPF:全屏同时显示两个窗口(扩展桌面)

转载 作者:可可西里 更新时间:2023-11-01 11:14:54 27 4
gpt4 key购买 nike

我只想了解如何在全屏模式下运行两个 WPF 窗口(一个在扩展桌面中)。

最佳答案

添加 System.Windows.Forms.dll 和 System.Drawing.dll 引用并试试这个:

public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);

foreach (var screen in System.Windows.Forms.Screen.AllScreens)
{
var window = new Window1
{
WindowStartupLocation = WindowStartupLocation.Manual,
WindowState = WindowState.Maximized,
WindowStyle = WindowStyle.None,
Title = screen.DeviceName,
Width = screen.Bounds.Width,
Height = screen.Bounds.Height,
Left = screen.Bounds.Left,
Top = screen.Bounds.Top,
};
window.Show();
}
}
}

不要忘记从 App.xaml 中删除 StartupUri="Window1.xaml"。

关于c# - WPF:全屏同时显示两个窗口(扩展桌面),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2514712/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com