我想让WPF程序在俩个显示器中拼接共享一张图片,搜了好多资料大都是指定哪个屏幕显示,并不是我想要的,所以自己根据WPF 控件 <Viewbox> 做了一个Demo。
效果图如下:
前段代码如下:
<Window x:Class="WpfApp2.MainWindow"
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:WpfApp2"
mc:Ignorable="d" WindowStartupLocation="Manual"
Title="MainWindow" Height="1080" Width="3840" WindowStyle="None" AllowsTransparency="True">
<Grid Width="3840" Height="1080">
<Viewbox Stretch="Fill">
<Image Source="/imgs/123.jpg" />
</Viewbox>
</Grid>
</Window>
后端代码如下:
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : System.Windows.Window
{
public MainWindow()
{
InitializeComponent();
this.WindowStartupLocation = WindowStartupLocation.Manual;
this.Left = 0;
this.Top = 0;
}
}