Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在WPF中管理两个单独的显示?_Wpf_Visual Studio_Caliburn.micro - Fatal编程技术网

如何在WPF中管理两个单独的显示?

如何在WPF中管理两个单独的显示?,wpf,visual-studio,caliburn.micro,Wpf,Visual Studio,Caliburn.micro,我正在编写一个应用程序,允许用户在触摸屏上选择一系列地图,然后地图也会显示在更大的壁挂式屏幕上。用户将能够围绕地图进行平移/缩放/旋转,我希望壁挂式屏幕能够与触摸屏同步显示这些变化 管理这两个显示器的好方法是什么 目前,我已将应用程序设置为MVVM格式,并使用Caliburn.Micro 每个映射都在其自己的UserControl中,它们在我的ShellView上的ContentControl中使用ShellViewModel中的Conductor和ActivateItem激活。我希望活动项目也

我正在编写一个应用程序,允许用户在触摸屏上选择一系列地图,然后地图也会显示在更大的壁挂式屏幕上。用户将能够围绕地图进行平移/缩放/旋转,我希望壁挂式屏幕能够与触摸屏同步显示这些变化

管理这两个显示器的好方法是什么

目前,我已将应用程序设置为MVVM格式,并使用Caliburn.Micro

每个映射都在其自己的UserControl中,它们在我的ShellView上的ContentControl中使用ShellViewModel中的Conductor和ActivateItem激活。我希望活动项目也显示在一个单独的窗口中(在墙上安装的屏幕上)

以下是迄今为止的代码:

ShellView.xaml:

    <Grid>
        <!--The Content control shows which MapView is currently active-->
        <ContentControl x:Name="ActiveItem"/>
            <StackPanel>
                <TextBlock Text="Select a map.">
                <ComboBox>
                    <Button x:Name="LoadMap1">Map1</Button>
                    <Button x:Name="LoadMap2">Map2</Button>
                    <Button x:Name="LoadMap3">Map3</Button>
                </ComboBox>
            </StackPanel>
    </Grid>

Map1
Map2
Map3
ShellViewModel.cs:

    public class ShellViewModel : Conductor<object>
    {
        public ShellViewModel()
        {

        }

        public void LoadMap1()
        {
            ActivateItem(new MapOneViewModel());
        }

        public void LoadMap2()
        {
            ActivateItem(new MapTwoViewModel());
        }

        public void LoadMap3()
        {
            ActivateItem(new MapThreeViewModel());
        }
    }

公共类ShellViewModel:导体
{
公共ShellViewModel()
{
}
公共void LoadMap1()
{
ActivateItem(新的MapOneViewModel());
}
公共void LoadMap2()
{
ActivateItem(新的MapTwoViewModel());
}
公共void LoadMap3()
{
ActivateItem(新的MapThreeViewModel());
}
}
我不知道这是否是最好的设置方法,但它可以很好地在ShellView上加载地图。我真的需要在另一个窗口中为壁挂式显示器显示相同的内容


感谢您的帮助,谢谢

假设您的显示器都连接到同一个设备,您可以使用
Forms.Screen
获取每个显示器的边界。然后将窗口设置为相同的边界,添加一个已加载的
事件处理程序以最大化它们,并调用
Show()


假设您的显示器都连接到同一设备,您可以使用
Forms.Screen
获取每个显示器的边界。然后将窗口设置为相同的边界,添加一个已加载的
事件处理程序以最大化它们,并调用
Show()


您可以查看Caliburn.Micro内置
WindowManager
您可以查看Caliburn.Micro内置
WindowManager
public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        var primaryScreen = System.Windows.Forms.Screen.PrimaryScreen;
        this.MainWindow = new Window();
        this.MainWindow.Content = new TextBlock { Text = "This is the primary display." };
        this.MainWindow.Left = primaryScreen.Bounds.Left;
        this.MainWindow.Top = primaryScreen.Bounds.Top;
        this.MainWindow.Width = primaryScreen.Bounds.Width;
        this.MainWindow.Height = primaryScreen.Bounds.Height;
        this.MainWindow.WindowState = WindowState.Normal;
        this.MainWindow.Loaded += (_s, _e) => this.MainWindow.WindowState = WindowState.Maximized;
        this.MainWindow.Show();

        var secondaryScreen = System.Windows.Forms.Screen.AllScreens.First(screen => screen != primaryScreen);
        var secondaryWindow = new Window();
        secondaryWindow.Content = new TextBlock { Text = "This is the secondary display." };
        secondaryWindow.Left = secondaryScreen.Bounds.Left;
        secondaryWindow.Top = secondaryScreen.Bounds.Top;
        secondaryWindow.Width = secondaryScreen.Bounds.Width;
        secondaryWindow.Height = secondaryScreen.Bounds.Height;
        secondaryWindow.WindowState = WindowState.Normal;
        secondaryWindow.Loaded += (_s, _e) => secondaryWindow.WindowState = WindowState.Maximized;
        secondaryWindow.Show();

    }
}