开发者

Which has better rendering performance, Stackpanel or Canvas+TranslateTransform? WPF/Silverlight

开发者 https://www.devze.com 2022-12-11 11:46 出处:网络
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 expli

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.

I开发者_如何学Pythons this true?

Anyone have any data either way?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号