我正在尝试创建一个 WPF 演示应用程序,其中主屏幕上的主窗口将用于更新演示窗口上的内容,该窗口需要位于辅助屏幕上。我正在寻找可以帮助我做到这一点的示例或代码片段。
我也尝试了以下但不起作用:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var screens = System.Windows.Forms.Screen.AllScreens;
if (screens.Length > 1)
{
var window = new MainWindow
{
WindowStartupLocation = WindowStartupLocation.Manual,
WindowState = WindowState.Maximized,
Top = screens[0].WorkingArea.Top,
Left = screens[0].WorkingArea.Left,
Topmost = true
};
window.Show();
var pesentationWindow = new PresentationWindow
{
WindowStartupLocation = WindowStartupLocation.Manual,
ShowInTaskbar = false,
Top = screens[1].WorkingArea.Top,
Left = screens[1].WorkingArea.Left,
Topmost = true
};
pesentationWindow.Show();
}
}