2016-07-04 72 views
0

我正在使用Windows通用应用程序。我在UWP中有关于打印功能的问题。在此问题中,当我点击打印按钮时,它打印出动态设计的发票页面,但打印不包括整个页面布局。打印版面不包含xaml页面的整个版面?

我只是把我的xaml代码。

<Grid Background="White"> 

     <Grid Name="gridpopup" Visibility="Visible" Background="White"> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="50"></RowDefinition> 
       <RowDefinition Height="200"></RowDefinition> 
       <RowDefinition Height="*"></RowDefinition> 
       <RowDefinition Height="78"></RowDefinition> 
       <RowDefinition Height="150"></RowDefinition> 

      </Grid.RowDefinitions> 

      <StackPanel Orientation="Horizontal" Margin="10,10,0,0" Grid.Row="0"> 
       <TextBlock FontFamily="Arial Narrow" Text=" Print Order :" FontSize="20" Height="50" VerticalAlignment="Bottom" Foreground="#FFF05929" FontWeight="Bold" Margin="0,0,0,-10"/> 
       <TextBlock x:Name="invoice_inc_id" FontFamily="Arial Narrow" Text="{Binding id" FontSize="20" Height="40" VerticalAlignment="Top" Foreground="#FFF05929" FontWeight="Bold"/> 
      </StackPanel> 

      <StackPanel Grid.Row="1" BorderBrush="LightGray" BorderThickness="0,1,0,2"> 
       <Image Name="logo" Height="70" Margin="220,10,220,0"/> 
       <StackPanel Orientation="Horizontal" Margin="10,35,0,0" Height="36"> 
        <TextBlock FontFamily="Arial Narrow" Text=" Customer Name: " FontSize="18" Height="30" VerticalAlignment="Top" Foreground="Black" Margin="0,6,0,0"/> 
        <TextBlock Margin="15,7,0,0" Name="invoice_Customername" FontFamily="Arial Narrow" Text="{Binding customer_name}" FontSize="18" Height="24" VerticalAlignment="Top" Foreground="Black" /> 
       </StackPanel> 
       <StackPanel Orientation="Horizontal" Margin="12,10,-2,0" Height="36" HorizontalAlignment="Left" > 
        <TextBlock FontFamily="Arial Narrow" Text=" Phone/Email : " FontSize="18" Height="40" VerticalAlignment="Bottom" Foreground="Black" Margin="0,-4,0,0"/> 
        <TextBlock Margin="15,-5,0,0" Name="invoiceCustomeremail" FontFamily="Arial Narrow" Text="{Binding customer_email}" FontSize="18" Height="36" VerticalAlignment="Top" Foreground="Black" Width="210" /> 
       </StackPanel> 
      </StackPanel> 

      <ListView Grid.Row="2" Name="lstinvoice" IsHitTestVisible="False" BorderBrush="LightGray" BorderThickness="0,0,0,1"> 
       <ListView.Background> 
        <ImageBrush Stretch="Fill" ImageSource="Images/LoginImages/gradient_bg.png"/> 
       </ListView.Background> 
       <ListView.HeaderTemplate> 
        <DataTemplate> 
         <Grid Margin="0,5,0,8" Height="25"> 
          <Grid.ColumnDefinitions> 
           <ColumnDefinition Width="400"></ColumnDefinition> 
           <ColumnDefinition Width="200"></ColumnDefinition> 
           <ColumnDefinition Width="200"></ColumnDefinition> 
          </Grid.ColumnDefinitions> 
          <TextBlock Grid.Column="0" Text="Name" Foreground="#FF020202" FontSize="24" FontWeight="Bold" FontFamily="Raavi" SelectionHighlightColor="#FFE05022" VerticalAlignment="Center" Margin="25,0,2,3" Height="31"></TextBlock> 
          <TextBlock Grid.Column="1" Text="Quantity" Foreground="#FF040404" FontSize="24" FontWeight="Bold" FontFamily="Raavi" SelectionHighlightColor="#FFE05022" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,-5,-9"></TextBlock> 
          <TextBlock Grid.Column="2" Text="Price" Foreground="#FF080808" FontSize="24" FontWeight="Bold" FontFamily="Raavi" SelectionHighlightColor="#FFE05022" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,30,-9"></TextBlock> 

         </Grid> 
        </DataTemplate> 
       </ListView.HeaderTemplate> 
       <ListView.ItemTemplate> 
        <DataTemplate> 
         <StackPanel Grid.Row="2"> 
          <Grid> 
           <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="400"></ColumnDefinition> 
            <ColumnDefinition Width="200"></ColumnDefinition> 
            <ColumnDefinition Width="200"></ColumnDefinition> 
           </Grid.ColumnDefinitions> 
           <TextBlock Grid.Column="0" FontFamily="Arial Narrow" Text="{Binding name}" FontSize="18" Height="40" VerticalAlignment="Center" Foreground="Black" Margin="10,0,0,0" Width="400" TextWrapping="Wrap"/> 
           <TextBlock Grid.Column="1" FontFamily="Arial Narrow" Text="{Binding ordered_qty}" FontSize="18" Height="40" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="Black" Margin="0,0,28,0" Width="auto"/> 
           <TextBlock Grid.Column="2" FontFamily="Arial Narrow" Text="{Binding unit_price}" FontSize="18" Height="40" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="Black" Margin="0,0,40,0" Width="auto"/> 

          </Grid> 
         </StackPanel> 
        </DataTemplate> 
       </ListView.ItemTemplate> 
      </ListView> 
<Grid Grid.Row="3" Grid.RowSpan="2" Name="disscount_pnl_detail" Width="450" VerticalAlignment="Top" HorizontalAlignment="Left"> 
       <Grid.RowDefinitions> 
        <RowDefinition Height="22"></RowDefinition> 
        <RowDefinition Height="22"></RowDefinition> 
        <RowDefinition Height="22"></RowDefinition> 
        <RowDefinition Height="22"></RowDefinition> 
        <RowDefinition Height="22"></RowDefinition> 
       </Grid.RowDefinitions> 

       <Grid.ColumnDefinitions> 
        <ColumnDefinition Width="300"></ColumnDefinition> 
        <ColumnDefinition Width="150"></ColumnDefinition> 
       </Grid.ColumnDefinitions> 

       <TextBlock FontFamily="Arial Narrow" Text="Sub Total : " Grid.Row="0" Grid.Column="0" FontSize="18" TextAlignment="Right" Foreground="Black" Height="22" /> 
       <TextBlock Name="invoice_subtotal" Grid.Row="0" Grid.Column="1" Text="$0.00" HorizontalAlignment="Left" TextAlignment="Right" Foreground="#FFFF3400" FontSize="20" /> 

       <TextBlock FontFamily="Arial Narrow" Text="Discount : " Grid.Column="0" Grid.Row="1" FontSize="18" TextAlignment="Right" Foreground="Black" Height="22" /> 
       <TextBlock Text="$0.00" Name="invoice_discount" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" TextAlignment="Right" Foreground="#FFFF3400" FontSize="20" /> 


       <TextBlock FontFamily="Arial Narrow" Text="Tax : " Grid.Row="2" Grid.Column="0" FontSize="18" TextAlignment="Right" Foreground="Black" Height="22" /> 
       <TextBlock Text="$0.00" Name="invoice_tax" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Left" TextAlignment="Right" Foreground="#FFFF3400" FontSize="20" /> 

       <TextBlock FontFamily="Arial Narrow" Text="Shipping And Handling : " FontSize="18" Foreground="Black" TextAlignment="Right" Grid.Row="3" Grid.Column="0" /> 
       <TextBlock Name="invoice_shippingcharge" Text="$0.00" HorizontalAlignment="Left" Foreground="#FFFF3400" TextAlignment="Right" FontSize="20" Grid.Row="3" Grid.Column="1" /> 

       <TextBlock FontFamily="Arial Narrow" Text="Grand Total :" FontSize="22" Foreground="Black" TextAlignment="Right" FontWeight="Bold" Grid.Row="4" Grid.Column="0"/> 
       <TextBlock Name="invoice_grandtotal" Text="$0.00" HorizontalAlignment="Left" Foreground="#FFFF3400" FontSize="20" TextAlignment="Right" Grid.Row="4" Grid.Column="1" /> 


      </Grid> 
    </Grid> 




    </Grid> 
</Page> 

图片: enter image description here

回答

0

要解决这个问题,你可以为那些TextBlock设置FontFamily。一旦您在TextBlock中添加FontFamily,它们将被正确打印。

我们可以设置FontFamily那些TextBlock<TextBlock Name="invoice_subtotal" FontFamily="Arial Narrow" .../>一个接一个。或者,正如所有TextBlock s的使用“窄Arial”字体,我们可以设置它的风格,针对所有TextBlock S IN此Grid

<Grid Name="gridpopup" Background="White" Visibility="Visible"> 
    <Grid.Resources> 
     <Style TargetType="TextBlock"> 
      <Setter Property="FontFamily" Value="Arial Narrow" /> 
     </Style> 
    </Grid.Resources> 
    ... 
</Grid> 
+0

谢谢你这么多严重。我一直在过去10天面对这个问题。你是如此的天才。事实上,我尝试了很多,但我没有得到任何解决方案。但非常感谢你这个解决方案。 –