3

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

1
  • I don't understand why the first line isn't accounted, but Hi everyone
    – Kraenys
    Commented Aug 13, 2014 at 11:33

1 Answer 1

5

Use PrintDialog and pass the interface

PrintDialog dialog = new PrintDialog();
dialog.PrintVisual(this.YourLayoutName, "");
2
  • 1
    This is precisely what i was looking for. Thank you Sajeetharan!
    – Kraenys
    Commented Aug 13, 2014 at 12:34
  • So you could also just generate the layout without "displaying" it to the user? Lets say, you see a page, you press "print" and another layout is beïng printed?
    – Robin
    Commented Apr 24, 2018 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.