问题
I am experiencing an extremely wired WPF PrintDialog issue -- Windows XP64 + VS2010.
It is pretty unbelievable that it is very very slow to get PrintDialog's .PrintableAreaWidth or .PrintableAreaHeight property.
// see sample codes below - remember to include "using System.Windows.Controls"
PrintDialog pd = new PrintDialog();
double pw = pd.PrintableAreaWidth; // set a break-point here, very slow, why???
double ph = pd.PrintableAreaHeight;
Anyone has any idea regarding this? I appreciate any thoughts!
回答1:
The PrintableArea
refers to the actual Printer in use - your app has to contact the printer to get that info, and my guess is that's the reason why it's slow. It shouldn't be any faster in WinForms...
If you'd want to optimize, you could cache the printer name and it's defaults and use that instead of querying the printer each time.
来源:https://stackoverflow.com/questions/4187395/wpf-why-too-slow-to-get-printdialogs-printableareawidth-and-printableareahei