我有两个用于打印的页面 .
1)PagePrinting.xaml
2)FormattedPage.xaml
在PagePrinting.xaml中,我使用下面的代码来引用FormattedPage.xaml
FrameworkElement page1;
page1 = new FormattedPage();
CanvasPrintContainer.Children.Add(第1页);
问题:
- txtBlkDatePrint在PagePrinting.xaml中显示时为空白
我需要做什么?
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>
1 回答
所以,
Paragraph
将Block
的集合作为Content
,其中TextBlock
具有讽刺意味 . 请尝试使用Run
.但是,如果您只想显示简单文本,则可能根本不需要
RichTextBlock
.