Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Bind to the list of installed printers [duplicate]

How to bind to the list of System.Drawing.Printing.PrinterSettings.InstalledPrinters, which is a static StringCollection, in WPF XAML. For example, to use it in a ComboBox, so a user can select the printer to use.

like image 626
Mike de Klerk Avatar asked Nov 21 '12 08:11

Mike de Klerk


1 Answers

Add the namespace for System.Drawing.Print to your XAML code:

xmlns:Printing="clr-namespace:System.Drawing.Printing;assembly=System.Drawing"

Then add the combobox to show the list of printers installed on the system:

<ComboBox Name="cmbPrinterSelection" Width="300" ItemsSource="{x:Static Printing:PrinterSettings.InstalledPrinters}" SelectionChanged="cmbPrinterSelection_SelectionChanged" />

Hopefully this will save someone some time.

like image 119
Mike de Klerk Avatar answered Oct 31 '22 16:10

Mike de Klerk