Introduction

Microsoft's documentation & sample for printing is too complex. The sample app for printing only shows you how to print the RichTextBlock. There's no tutorial available on printing the TextBox content in the Windows Store app. Moreover to print a single line of string, one has to write too many codes rather than a maximum of 10 lines in the WinForm. So this helper class provides the simplest method to print the text box content. It has only one static method. And it prints the text box content along with its formatting. It's majorly based on the MSDN print sample.

I got the idea to write a library from the following Stack Overflow questions.

How to print the contents of a TextBox ?
How do you print contents of a RichTextBox ?
How do I print a TextFile OR contents of a TextBox in Metro apps ?

How to use it?

You have to call just one static method ShowPrintUIAsync of the class Printer and it will do the print job on your behalf.

await Printer.ShowPrintUIAsync(PrintPreview, MyTextBox, Guid.NewGuid().ToString());

To install the WinRT.TextboxPrintHelper as NuGet package, run the following command in the Package Manager Console.

Image1.jpg

I would be glad to have issues or suggestions from you, so that I can improve this. If you want to fork the repository or post issues, find this helper class on GitHub.