我有两个用于打印的页面。
1)PagePrinting.xaml
2)FormattedPage.xaml
在PagePrinting.xaml中,我使用下面的代码来引用FormattedPage.xaml
FrameworkElement page1;
page1 = new FormattedPage();
CanvasPrintContainer.Children.Add(第1页);
问题:
我需要做什么?
in CodeBehind of FormattedPage.xaml : protected override void OnNavigatedTo(NavigationEventArgs e) { txtBlkDatePrint.Text = DateTime.Today.ToString("d"); } FormattedPage.xaml: < StackPanel x:Name="header" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="0" Height="60"> <StackPanel Orientation="Horizontal" > <RichTextBlock Foreground="Black" FontSize="20" TextAlignment="Left" FontFamily="Segoe UI"> <Paragraph> <TextBlock x:Name="txtBlkDatePrint" Margin="10,10,0,0" HorizontalAlignment="Left" TextWrapping="Wrap" FontSize="28" Text="" VerticalAlignment="Top" Height="39" Width="204"/> </Paragraph> </RichTextBlock> </StackPanel> </StackPanel>
答案 0 :(得分:0)
因此,Paragraph
将Block
的{{1}}收集为Content
,其中TextBlock
具有讽刺意味。请尝试使用Run
。
<StackPanel x:Name="header" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="10,10,0,0" Grid.Row="0" Height="60">
<StackPanel Orientation="Horizontal" >
<RichTextBlock Foreground="Black" FontSize="20" TextAlignment="Left" FontFamily="Segoe UI">
<Paragraph>
<Run x:Name="txtBlkDatePrint" TextWrapping="Wrap" FontSize="28" Text=""/>
</Paragraph>
</RichTextBlock>
</StackPanel>
</StackPanel>
但是,如果您只想显示简单文字,则可能根本不需要RichTextBlock
。