开发者

WPF Performance: Templates vs. UserControls

This is a kind of non-objective question, since I think that the mileage may vary, but, given a scenario where I can use a Control Template (declared at the Resources section of my Page) or a UserControl, which would result in the best performance?

The reason for asking is that I've just had a performance issue with WPF (trying to create a table -- grid -- with as many as 5000 controls) and one开发者_JS百科 thing that I did in order to improve the performance of the page was converting one control template (which represented one row within the grid) to a UserControl, which I suspected would bring better perfomance. But after profiling the code, I've found out that I actually lost performance -- not much, but enough for me to go back to the old code.

Anyone has any insight on the matter?


For your question I don't have a good answer. However having a grid with 5000 controls sounds scaring. I would try to use a virtualizing-technology such as VirtualizingStackPanel, so that your controls will be recycled and only created if necessary (if possible).

Maybe this post gives you an idea.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜