wpf应用程序在不同的屏幕上运行

时间:2017-09-24 10:05:59

标签: c# wpf printing

我有一个在不同屏幕上运行的应用程序。 我在窗口准备了4个大小的表格。 当我在电脑上运行时,42英寸电视没有任何问题。 我尝试在另一台22英寸的电脑上安装应用程序,屏幕在视觉上和打印时切割我的窗口。 它遵循我的xaml和c#代码进行打印

<StackPanel Background="White" Height="29.7cm" Width="19.5cm" >
 <StackPanel Name="StackFoglioA4Pag1" HorizontalAlignment="Center" Margin="20" Background="White">
                            <!--<TextBox HorizontalContentAlignment="Center" BorderBrush="Black" Text="ciane S.p.A." VerticalContentAlignment="Center" IsReadOnly="True" FontWeight="Bold" FontFamily="Times New Roman" FontSize="14"></TextBox>
                            <TextBox Padding="2" HorizontalContentAlignment="Center" BorderBrush="Black" BorderThickness="1,0,1,1"  Text="Main "-  VerticalContentAlignment="Center" IsReadOnly="True" FontFamily="Times New Roman" FontSize="9"></TextBox>
                            <TextBox Padding="2" HorizontalContentAlignment="Center" BorderThickness="1,0,1,1"  BorderBrush="Black" Text="textggggggg  " VerticalContentAlignment="Center" IsReadOnly="True" FontFamily="Times New Roman" FontSize="9"></TextBox>-->
                            <DockPanel Margin="0,5,0,0">
                     <!--etc etc   

public static void StampaStackPanel(StackPanel StackPanel,string message)
    {
        PrintDialog stampa = new PrintDialog();
        if (stampa.ShowDialog() != true) return;

        stampa.PrintVisual(StackPanel,message);
    }

编辑:

在我的电脑中,我看到图像已满,而在另一台显示器(更大)我看到它已切割

enter image description here

更新: enter image description here

2 个答案:

答案 0 :(得分:0)

尝试

stampa.Location = new Point(//WhereYouWanX, //WhereYouWantY);

答案 1 :(得分:0)

Windows.Forms.Screen

var view= new YourView();
var screens = System.Windows.Forms.Screen.AllScreens[1].WorkingArea;
view.Location = new Point(rectMonitor.Left, rectMonitor.Top);
相关问题