Reputation: 4332
I have two Pages used for printing.
1) PagePrinting.xaml
2) FormattedPage.xaml
in PagePrinting.xaml , I used the code below to reference the FormattedPage.xaml
FrameworkElement page1;
page1 = new FormattedPage();
CanvasPrintContainer.Children.Add(page1);
The problem:
What I need to do?
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>
Upvotes: 0
Views: 55
Reputation: 5575
So, Paragraph
takes in a collection of Block
s as Content
, of which TextBlock
ironically is not. Try instead using a 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>
Though, if you just want to display simple text, you may not need the RichTextBlock
at all.
Upvotes: 0