UI Frontiers: Silverlight Printing Basics

Get a handle on the nuts and bolts of adding printing capabilities to your Silverlight apps as Charles walks through programs to print an ellipse, an image and a calendar.

 
 
 
 
 
(4)
7,135 times
Add to favorites
5/3/2011
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • I want to print Selected Records on canvas (For Demand Draft Printing) using silverlight 4 C#.
    1 Posts | Last post November 04, 2011
    • 1: on my mainpage.xmal I taken Data grid with Check box selection and Canvas.
      
      2: I want to print Selected record on Canvas but it is not printing it give a exception error,
      
      i.e Dialogs must be user-initiated.(Security Exception was unhanded by user) following code i do but it not working properly pl help me to do this.
      
      private void btnPrint_Click(object sender, RoutedEventArgs e)
      {
      int count = 0;
      int printCount = 0;
      PrintDocument docToPrint = new PrintDocument();
      
      foreach (ServiceReference1.DDDEMO dd in obcDDDemo)// here DDDEMO is table and "obcDDDemo" is ObservableCollection class.
      {
      textBlock1.Text =dd.Name.ToString(); //Payee name.
      textBlock2.Text =dd.Amount.ToString();//Amount
      
      docToPrint.PrintPage += (s, args) =>
      {
      args.PageVisual = canvas1;
      printCount++;
      
      if (printCount < count)
      {
      args.HasMorePages = true;
      }
      else
      {
      args.HasMorePages = false;
      }
      };
      docToPrint.Print("Document");
      }
      } 
  • Landscaping a user control
    1 Posts | Last post July 18, 2011
    • Dear Sir,
      
      This is a great article.
      
      My problem is similar to what you described for landscape printing, but at the same time it is little bit different.
      
      My user control that is being used as page visual is defined with various data templates (uses a data grid).
      
      Printing in landscape from the print control dialog box works great but I want to print my user control in landscape mode by default. I tried several options none seem to give me the same effect as that of the print control dialog (from MS).
      
      In the example you described you used an Image so we would know its pixel widths and heights. But in my case it is a user control whose width and height are determined based on data at run time. So I am not sure how print dialog is able to figure out how to correctly landscape it, but I am not?
      
      Could you shed some light?
      
      Regards,
      Satya