WPF 选项卡切换/渲染花费太多时间

发布于 2024-10-08 19:06:05 字数 197 浏览 0 评论 0原文

我有一个带有许多选项卡的 WPF 应用程序.. 在一个选项卡中..我制作了一个非常复杂的矢量绘图,其中包含数千个绘图视觉效果..(这代表一台机器,所有元素都需要可交互..) 第一次绘制它需要 3/4 秒。第一次绘制后应该完成。

问题是如果我切换到另一个选项卡并返回,则至少需要 2.3 秒才能显示带有绘图的选项卡页再次..既然没有重绘,为什么要花这么多时间..?

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 seconds 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..?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧情别恋 2024-10-15 19:06:05

如果组件不会更改,您可以对其调用 Freeze() 将其标记为已完成。如果没有尝试过,我不知道这是否有帮助,但你可以尝试一下。

并非所有对象都是可冻结的。查看 MSDN 文档以获取更多信息:
http://msdn.microsoft.com/en-us/library/ms750509.aspx

您可以尝试的另一件事是将矢量艺术渲染为位图,并显示它。也许失去矢量精度会让你感到讨厌,但如果你知道它不会改变并且看起来会一样,那有什么坏处呢? (如果您支持打印或需要高分辨率版本的功能,您可以随时切换回该操作。)有关如何将 UIElement 转换为位图的信息,请查看:
http://msdn.microsoft.com/en -us/library/system.windows.media.imaging.rendertargetbitmap.aspx

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

平生欢 2024-10-15 19:06:05

另一种可能的解决方案:您并没有真正解释您正在与元素进行什么样的交互,但如果您想做的只是缩放和平移,那么 RenderTransform 可能就足够了(这更有效)比 LayoutTransform 和/或单独移动所有元素更高效)。我还没有尝试过结合 Freeze()RenderTransform,但您也许能够获得所需的缩放,同时减少 WPF 必须执行的布局量。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文