How to print the contents of a TextBox

jay_t55 picture jay_t55 · Mar 22, 2013 · Viewed 27.9k times · Source

How do I print the contents of a TextBox in metro apps? I have read this quickstart guide on MSDN and many online tutorials, but they are very complicated and do not work with TextBox controls, only RichTextBox controls.

How do we print from a TextBox control in a metro app? Is it even possible? How?

Answer

Farhan Ghumra picture Farhan Ghumra · Mar 25, 2013

UPDATE 1

I have created a helper class which simplifies printing text box content. You can add helper class via NuGet. If you want to enhance my existing helper class, fork on GitHub


Here I am giving you the modified print sample from MSDN. I have put textbox you can write anything and that will be printed. Please note I have not done sample which prints textbox text exactly same as it is i.e formatting (bold, italic, underline, colors). I have set hard-coded print format. You can make your own format.

Stack Overflow has character limit in answer and my code is too long so posting CodePaste.net links.

XAML : http://codepaste.net/9nf261

CS : http://codepaste.net/q3hsm3

Please note that I have used some images so put images in "Images" folder