Silverlight / WPF - Print Generic List values in Silverlight

Asked By gopal krish on 21-Jun-12 07:55 AM
Earn up to 10 extra points for answering this tough question.
hi..

i need to Print Generic List values in Silverlight?

need ur suggestions with examples..

regards
gopal.s
[)ia6l0 iii replied to gopal krish on 21-Jun-12 10:29 PM
If you have Silverlight version 3, you cannot. You have to custom write the objects or render them as bitmap's I guess.

In Silverlight version 4, the PrintDocument class was introduced. Well, I hope you have not scoured the holy internet yet for any articles. David Poll had this article titled "Making printing easier in Silverlight 4" on his blog much much earlier. Here is the link from my bookmarks - http://www.davidpoll.com/2010/04/16/making-printing-easier-in-silverlight-4/

In short,  you need to create a print document, give it a name. Associate the PrintPage handler and in the handler , add the elements to the pageRoot children. And then call the print method.

var pd = new PrintDocument();
pd.DocumentName = "custom print";
pd.PrintPage += pd_PrintPage;
pd.Print();

private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
    var pageRoot = new Canvas();
    e.PageVisual = pageRoot;
    pageRoot.Children.Add(control1);

}


Hope it helps.
Vikram Singh Saini replied to gopal krish on 23-Jun-12 05:06 AM
The author at link  http://www.thomasclaudiushuber.com/blog/2009/12/10/how-to-print-a-liststring-in-silverlight-4-beta-over-multiple-pages/  suggests how to print List values of type string in silverlight. The code has been provided by author and explained very well.

Here is the link for downloading entire source code: http://www.thomasclaudiushuber.com/dotnet/20091210_ThomasClaudiusHuber_PrintStringListInSilverlight4Beta.zip

Hope the links would help you to understand all.