I am trying to print a page from my Universal Windows Store app.
I currently have it set up that I get a list of tuples, (contains the data to be put on the printed pages: string
and ImageSource
), and when the user wants to print, a new PrintPage
(custom subclass of Page
, styled using XAML) is instantiated, and I set the elements on my PrintPage
using this code:
public PrintPage(Tuple<string, ImageSource> tuple) {
Title.Text = tuple.Item1;
Image.Source = tuple.Item2;
}
where my XAML is this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="10*"/>
</Grid.RowDefinitions>
<TextBlock Name="Title"/>
<Image Grid.Row="1" Name="Image" Stretch="Uniform"/>
</Grid>
The ImageSource
is rendered using the following code (and displayed on a page to have the user choose what to print):
RenderTargetBitmap Bitmap = new RenderTargetBitmap();
await Bitmap.RenderAsync(DrawingArea); // DrawingArea is a `Grid` containing my elements
Now when I print my page, on the preview and on the printed page, I cannot see my image. What am I doing wrong?