title: PrintDialog.PrinterSettings equivalent in WPF
body: <p>I'm trying to add printing support to a C# WPF application I'm writing and I'm tearing my hair out over this.  I'm trying to print a single image from a window in a WPF application.  The image is a shipping label and the printer is a thermal printer loaded with 4"x6" shipping label stock.  The code to print is as follows:</p>
  
  <pre><code>PrintDialog pd = new PrintDialog();
  
  if (pd.ShowDialog() == true)
  {
      Image tmpImage = new Image();
      tmpImage.Stretch = Stretch.Uniform;
      tmpImage.Width = pd.PrintableAreaWidth;
      tmpImage.Source = this.img_label.Source;
      tmpImage.Measure(new Size(pd.PrintableAreaWidth, pd.PrintableAreaHeight));
      tmpImage.Arrange(new Rect(new Point(0, 0), tmpImage.DesiredSize));
  
      pd.PrintVisual(tmpImage, "Shipping Label");
  }
  </code></pre>
  
  <p>This code works in that it will display the print dialog, I can choose my printer, configure it to use the correct label stock, and print the label.  However, as other posts have indicated, it does not save the settings I have selected.  So, if I choose to print the same image again without closing the application in between, it reverts to the default printer and, even when I choose the correct printer, defaults that printer to the default settings, which includes using the wrong size label stock.  So every time I print I have to select the printer and configure it to use the correct stock.  This is simply not acceptable in real world use.</p>
  
  <p>After much searching online I have found numerous posts about this but all of them talk about saving the <code>PrintDialog.PrinterSettings</code> object and then using that to initialize the next <code>PrintDialog</code> instance.  However, in WPF, there is no <code>PrinterSettings</code> member of the <code>PrintDialog</code> class.  That is a Win Forms object.  Why the Win Forms and WPF PrintDialog objects are different is beyond me, but that's likely a question that won't get answered.  The real question is what I do now.  I can, if necessary, re-invent the entire wheel and have my own printer selector and printer configuration pages and print the image using a <code>PrintDocument</code> object and bypass the <code>PrintDialog</code> entirely.  I'd rather not do this unless it is entirely necessary.  Displaying the <code>PrintDialog</code> is nice, it's what people are used to, and it already has all the ability to configure the printer built right in.  But how can I initialize the <code>PrintDialog</code> in WPF to select the proper printer and use the proper printer settings?  If only I were using Windows Forms this would be built in.  What's the WPF equivalent?</p>
  
  <p>The secondary question is, if there is no WPF equivalent, what is the recommended way to handle this?  I don't really need to give the user the ability to configure the printer within my application.  All I want it to do is remember the previous settings they chose the next time they go to print, just like every single other PC application that has ever been written.  How can this be so hard?</p>
  
  <p>Any help anyone can provide would be greatly appreciated.  In the mean time I'm going down the path of re-inventing the proverbial wheel.  I hope to get an easier answer soon.</p>
  
  <p>Thanks!</p>