I have had dealt with both LayoutTransform and RenderTransform and I know that each one is suited for a specific scenario which I had found a use for in previous projects.

Yet, from a performance perspective and while using a WPF profiling tool, for an instance, Which one has a lesser impact on the UI performance ?

有帮助吗?

解决方案

As specified by MSDN:

To apply transformations to a FrameworkElement, create a Transform and apply it to one of the two properties that the FrameworkElement class provides: LayoutTransform – A transform that is applied before the layout pass. After the transform is applied, the layout system processes the transformed size and position of the element. RenderTransform – A transform that modifies the appearance of the element but is applied after the layout pass is complete. By using the RenderTransform property instead of the LayoutTransform property, you can obtain performance benefits. Which property should you use? Because of the performance benefits that it provides, use the RenderTransform property whenever possible, especially when you use animated Transform objects. Use the LayoutTransform property when scaling, rotating, or skewing and you need the parent of the element to adjust to the transformed size of the element. Note that, when they are used with the LayoutTransform property, TranslateTransform objects appear to have no effect on elements. That is because the layout system returns the translated element to its original position as part of its processing.

And Also:

LayoutTransform can lead to poor application performance if you invoke it in a scenario that does not require a full pass by the layout system. When you apply a LayoutTransform to the Children collection of the Panel, it triggers a new pass by the layout system and forces all on-screen objects to be remeasured and rearranged. If you are updating the complete application user interface (UI), this functionality might be exactly what you need. However, if you do not need a full layout pass, use the RenderTransform property, which does not invoke the layout system, and therefore, is typically a better choice for this scenario.

其他提示

To add to gliderkite's answer, RenderTransforms will also be processed by the GPU when capable, whereas LayoutTransforms are done on the CPU.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top