Kraenys Kraenys - 2 months ago 8
C# Question

c# Print a page created by xaml

As the title said, i'm trying to print a page, created by xaml (the page looks like to a form)

At the end of the form, I have a button with an event Click.

<Button Grid.Row="15"
Grid.Column="3"
Click="ImpressionClick"
Height="50"
Width="150"
Grid.RowSpan="2"
Grid.ColumnSpan="3"
Content="Imprimer">
</Button>


My problem is: I have found how to print some text documents with C#, but i don't know how to print a page created with xaml code.

If someone know how to.

Thanks in advance.

Florian SELVA

Answer

Use PrintDialog and pass the interface

PrintDialog dialog = new PrintDialog();
dialog.PrintVisual(this.YourLayoutName, "");