<Window x:Class="DualMonitors.Views.WinLeft"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DualMonitors.Views"
mc:Ignorable="d" WindowState="Maximized" WindowStartupLocation="CenterScreen"
Title="WinLeft" Height="300" Width="300">
<Grid Background="Blue">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Left" FontSize="50" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Grid.Row="2" Command="{Binding LeftCmd}" Content="Click Left" FontSize="50"/>
</Grid> </Grid>
</Window>

<Window x:Class="DualMonitors.Views.WinRight"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DualMonitors.Views"
mc:Ignorable="d" WindowState="Maximized" WindowStartupLocation="CenterScreen"
Title="WinRight">
<Grid Background="Yellow">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="Right" FontSize="50" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Grid.Row="2" Command="{Binding RightCmd}" Content="Click Right" FontSize="50"/>
</Grid>
</Grid>
</Window>
using DualMonitors.ViewModel;
using System.Windows; namespace DualMonitors.Views
{
/// <summary>
/// Interaction logic for WinRight.xaml
/// </summary>
public partial class WinRight : Window
{
public WinRight()
{
InitializeComponent();
DualVM BDualVM = DualVM.GetDualVM();
this.DataContext = BDualVM;
}
}
}
using Prism.Commands;
using System.Windows; namespace DualMonitors.ViewModel
{
public class DualVM
{
private static DualVM DualVMInstance; public static DualVM GetDualVM()
{
object objLock = new object();
lock(objLock)
{
if(DualVMInstance==null)
{
DualVMInstance = new DualVM();
}
}
return DualVMInstance;
} private DualVM()
{
//MessageBox.Show("Dual Monitor");
} private DelegateCommand leftCmdValue;
public DelegateCommand LeftCmd
{
get
{
if(leftCmdValue==null)
{
leftCmdValue = new DelegateCommand(LeftCmdExecuted);
}
return leftCmdValue;
}
} private void LeftCmdExecuted()
{
MessageBox.Show("Left Monitor");
} private DelegateCommand rightCmdValue;
public DelegateCommand RightCmd
{
get
{
if(rightCmdValue==null)
{
rightCmdValue = new DelegateCommand(RightCmdExecuted);
}
return rightCmdValue;
}
} private void RightCmdExecuted()
{
MessageBox.Show("Right Monitor");
}
}
}
public partial class App : System.Windows.Application
{ protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e); SetupWindows();
} private void SetupWindows()
{
System.Windows.Forms.Screen mainScreen = Screen.AllScreens[]; ;
WinLeft leftWin = new WinLeft()
{
WindowStartupLocation = WindowStartupLocation.Manual,
WindowState = System.Windows.WindowState.Normal,
Left = mainScreen.WorkingArea.Left,
Top = mainScreen.WorkingArea.Top,
Width = mainScreen.WorkingArea.Width,
Height = mainScreen.WorkingArea.Height
}; System.Windows.Forms.Screen secondaryScreen = Screen.AllScreens[];
WinRight rightWin = new WinRight()
{
WindowStartupLocation = WindowStartupLocation.Manual,
WindowState = System.Windows.WindowState.Normal,
Left = secondaryScreen.WorkingArea.Left,
Top = secondaryScreen.WorkingArea.Top,
Width = secondaryScreen.WorkingArea.Width,
Height = secondaryScreen.WorkingArea.Height
}; leftWin.Show();
leftWin.WindowState = WindowState.Maximized;
rightWin.Show();
rightWin.WindowState = WindowState.Maximized;
rightWin.Owner = leftWin;
}
}

最新文章

  1. Zen of Python
  2. 记一个简单的保护if 的sh脚本
  3. 一次java性能调优总结
  4. C#迭代重载等
  5. 算法库:boost安装配置
  6. ZOJ 3349 Special Subsequence 简单DP + 线段树
  7. Xcode7工程改名
  8. getgpc($k, $t=&#39;GP&#39;),怎么返回的是 NULL?
  9. Spring MVC 的 XML 配置方式
  10. Caffe+CUDA8.0+CuDNNv5.1+OpenCV3.1+Ubuntu14.04 配置参考文献 以及 常见编译问题总结
  11. 15_Raid及mdadm命令 _LVM
  12. DevExpress v18.2新版亮点——DevExtreme篇(三)
  13. Typescript 发布到npm
  14. idea导入java项目
  15. 教你写Makefile(很全,含有工作经验的)
  16. Bootstrap如何关闭弹窗
  17. jq时间戳动画
  18. Hibernate学习笔记2.1(Hibernate基础配置)
  19. Why Linux Doesn’t Need Defragmenting
  20. bs-loading

热门文章

  1. SpringBootJPA实现增删改查
  2. IT兄弟连 HTML5教程 HTML5文字版面和编辑标签 小结及试题
  3. win7怎么使用远程桌面连接(win10类似,同样适用)
  4. CSS置换元素和非置换元素
  5. 深入理解 Java 数组
  6. Linux系统彻底卸载MySQL数据库
  7. 记录一次Mac VSCode运行Grpc模板项目
  8. Windowns系统下搭建python环境
  9. Loading class `com.mysql.jdbc.Driver&#39;. This is deprecated. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
  10. 转战物联网&#183;基础篇09-选择MQTT协议还是CoAP协议