【发布时间】:2015-10-03 02:42:13
【问题描述】:
所以我需要从 Windows 8 应用程序 (c# Xaml) 打印标签,并且我发现的所有示例都过于复杂,无法满足我的需求。 我的内容是一个单独的页面,包含一个文本块和一个图像,它们在页面加载时被填充,我需要做的就是打印该页面。是否有用于单个简单页面的简化打印方法(即不使用 RichTextBox 和溢出等)。对于感兴趣的,这是我需要打印的页面:
<Page
x:Class="Storeageapp.OutputforLabel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Storeageapp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Width="300" Height="200">
<Grid x:Name="printableArea">
<Grid.RowDefinitions>
<RowDefinition Height="3*"/>
<RowDefinition Height="3*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="header" Grid.Row="0" Grid.ColumnSpan="2" Height="60" Visibility="Collapsed">
</StackPanel>
<TextBlock x:Name="UID" Text="Hello World" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" />
<Image Source="" x:Name="scenarioImage" HorizontalAlignment="Center" Grid.Row="1" Grid.Column="0" Margin="10"/>
<StackPanel x:Name="footer" Grid.Row="4" Grid.Column="0" VerticalAlignment="Top" Visibility="Collapsed">
</StackPanel>
</Grid>
</Page>
如果有某种方法可以将其打印为图像,我会很高兴,但我无法弄清楚。 谢谢。 编辑:抱歉,这是在 Windows 商店应用程序中,而不是 WPF。
【问题讨论】: