移动的UIElement在Visual树不重新计算布局 [英] Move UIElement in Visual Tree without recalculating layout

查看:186
本文介绍了移动的UIElement在Visual树不重新计算布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在使用对接控制(Actipro)一个WPF应用程序(.NET 4.0)。我们可以停靠了对接的窗口。在这种情况下,一个真正的窗口被创建,内容被分配到该窗口。

We have a WPF application (.Net 4.0) using a Docking Control (Actipro). We can dock out the docking windows. In that case, a "real" Window is created and the content is assigned to that window.

当然,在可视化树动的东西会重新触发完整的布点。这是有问题的,因为在这些对接的一个窗口,我们有一个图表控件(Mindfusion线图示,WPF控件),可以采取长达10秒,完全布局本身(非常大图)。

Of course, moving stuff in the Visual Tree will re-trigger the complete layouting. This is problematic, because in one of these docking windows, we have a diagramming control (Mindfusion Diagramming,WPF control) that can take up to 10 seconds to completely layout itself (very large diagrams).

我不认为有任何直接的办法解决这个问题。我不知道怎么然而其他程序员类似问题走近了这个问题。有没有什么聪明的方法来避免重新计算布局?

I don't think that there's any direct solution to this problem. I wonder however how other programmers with similar issues approached this problem. Is there any clever way to avoid recalculating the layout?

在理论上,任何的确实的图,因为变化是一个内部的ScrollViewer,所以每当它被放置,缴费的空间量保持不变(无穷大)。

In theory, nothing really changes since the diagram is inside a ScrollViewer, so whenever it is placed, the amount of avaiable space remains the same(infinite).

编辑:另外请注意,图控件中是互动的。我们需要拖放放大器;删除。

Also note that the diagram control inside is interactive. We need Drag&Drop.

推荐答案

下面是一个想法。

  1. 创建一个自定义类的装饰继承。
  2. 包装你的装饰里面的图表控制。
  3. 覆盖的MeasureOverride然后简单base.Measure但结果存储在一个字段返回。
  4. 添加属性,它使您可以禁用措施通话。如果属性为true简单地返回,而不是调用base.Measure的previous大小的MeasureOverride。
  5. 设置属性同时改变了视觉层次。

从我的头顶,我想不出任何理由为什么这不应该工作。

From the top of my head I can't think of any reason why this shouldn't work.

其实我已经不是很久以前做了一些非常相似。当执行滑动动画的侧板在 NovaMind 我用了一个装饰以prevent内容从执行布局同时面板动画其宽度。我计算出的大小与最终的宽度,保存它,然后用的MeasureOverride伪造电流的大小。这prevented试图动画一个复杂的控制宽度时涉及的性能问题。 :)

I have actually done something very similar not too long ago. When implementing the sliding animation for the side panels in NovaMind I used a Decorator to prevent the content from performing layout while the panel animates its width. I calculated the size with the final width, stored it and then used MeasureOverride to fake the current size... This prevented the performance issues involved when trying to animate the width of a complex control. :)

这篇关于移动的UIElement在Visual树不重新计算布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆