Happy stress free coding

Sep 27, 2008

Printing wpf with xps

I needed to print a Canvas. This is the easiest possible solution (I think?!)

 
 

public void Print()

 

{

 

// Create the print dialog object and set options

 

System.Windows.Controls.PrintDialog pDialog = new System.Windows.Controls.PrintDialog();

 

pDialog.PageRangeSelection = PageRangeSelection.AllPages;

 

pDialog.UserPageRangeEnabled = true;

  
  
  
 

// Display the dialog. This returns true if the user presses the Print button.

 

Nullable<Boolean> print = pDialog.ShowDialog();

 

if (print == true)

 

{

 

pDialog.PrintVisual(CurrentPrintingCanvas(),"Modlr Diagram");

 

}

  
 

}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home