WPF: Why TOO SLOW to Get PrintDialog's .PrintableAreaWidth and .PrintableAreaHeight?

左心房为你撑大大i 提交于 2019-12-24 07:17:32

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!