Stackpanel 和 Canvas+TranslateTransform 哪个渲染性能更好? WPF/银光
当我布置视觉效果时,我总是使用 Canvas,因为我需要调整 RenderTransform.TranslateTransform 以某种方式制作动画。一位同事最近告诉我,除非我明确需要动画,否则我应该始终使用 A Stackpanel,因为在将对象布局到视觉效果时,它比 RenderTransform.TranslateTransform 更快。
这是真的吗?
有人有任何数据吗?
I always use a Canvas when I'm laying out my visuals usually because I will need adjust the RenderTransform.TranslateTransform to animate in some way. A colleague recently told me that unless I explicitly need to animate I should always use the A Stackpanel because it is faster than a RenderTransform.TranslateTransform when laying out objects to the visual.
Is this true?
Anyone have any data either way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有这方面的任何数据,但如果我们只是谈论堆叠,那么您使用 TranslateTransform 来实现每个项目的精确定位似乎非常脆弱,因为该项目理论上可以具有不同的高度/宽度,理论上也可以在运行时动态更改更不用说如果设计者手动更改它们,他们必须为 N 个其他 UI 元素重做翻译转换。使用 StackPanel 意味着将发生测量/排列阶段,并且无论项目的大小如何,它们都将被精确地布局。
I don't have any data on this, but if we're just talking about stacking then you using a TranslateTransform to achieve the exact positioning of each item seems extremely fragile since the item could theoretically be of different heights/widths which could also theoretically change dynamically at runtime not to mention if the designer changes them by hand they have to redo the translate transform for N other UI elements. Using StackPanel means the Measure/Arrange phases will occur and no matter what size the items are they will be laid out precisely.