开发者

WPF tabswitch/ render takes too much time

开发者 https://www.devze.com 2023-01-31 10:34 出处:网络
I have a WPF application with many tabs.. in one tab.. i make a verycomplex vector drawing consisting of thousands of drawing visuals.. (this represents a machine and all elements need to be interact

I have a WPF application with many tabs.. in one tab.. i make a verycomplex vector drawing consisting of thousands of drawing visuals.. (this represents a machine and all elements need to be interactable..) It takes 3/4 sec开发者_JAVA技巧onds for drawing this for the first time..After the first draw it should be done..

The problem is if i switch to another tab and comeback, it takes atlease 2,3 seconds to show the tabpage with drawing again.. Since there is no redraw, why should it take so much time..?


If the component is not going to change, you could call Freeze() on it to mark it as done. Without trying it out I don't know if that would help, but you could give it a shot.

Not all objects are Freezable. Check out the MSDN documentation for more info: http://msdn.microsoft.com/en-us/library/ms750509.aspx

Another thing you could try would be rendering the vector art to a bitmap, and displaying that. Maybe it makes you feel icky to lose the vector precision, but if you know it's not going to change and it will look the same, what's the harm? (If you support printing or something that will require a hi-res version, you could always switch back for that operation.) For info on how to convert a UIElement to a bitmap, check out: http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx


Another possible solution: You don't really explain what kind of interaction you are doing with the elements, but if all you want to do is zoom and pan, a RenderTransform may be good enough (which is more efficient than a LayoutTransform and/or moving all the elements individually). I haven't played around with combining Freeze() and a RenderTransform, but you may be able to get the desired zooming while reducing the amount of layout WPF has to do.

0

精彩评论

暂无评论...
验证码 换一张
取 消