Stackpanel 和 Canvas+TranslateTransform 哪个渲染性能更好? WPF/银光

发布于 2024-08-10 20:40:10 字数 215 浏览 11 评论 0原文

当我布置视觉效果时,我总是使用 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 技术交流群。

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

发布评论

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

评论(1

顾冷 2024-08-17 20:40:10

我没有这方面的任何数据,但如果我们只是谈论堆叠,那么您使用 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.

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