Reputation:
Does the rendering performance reduce seriously in case when WPF application's XAML contains a lot of nested Grid
, StackPanel
, DockPanel
and other containers?
Upvotes: 1
Views: 797
Reputation: 3563
WPF uses MeasureOverride
and ArrangeOverride
methods inorder to render UIElements. MeasureOverride
measure the UIElements width and size based on the Parent controls Width and Size. ArrangeOVerride
method will arrange the UIElements at runtime based on these measures. These methods are optimized for faster performance and should not cause any rendering performance issue.
But there should be a capacity where these methods can handle UIElements within a minimal time. If this limit exceeds then there should be performance issue.
eg: Suppose a bike can carry 2 person. if 5 persons overloaded what will happen :)
Jet Brains .Trace is a tool to analyze the performance issue which will helps to see these two methods
Upvotes: 0
Reputation: 14334
Really the answer is simply "yes". More of anything will use more processor time. SURPRISE!
In the case of WPF, elements are arranged into a hierarchical scene graph. Adding levels of depth to this graph will slow your application more than adding siblings to existing elements. You should always strive to keep the depth the graph low. Consider using Grid
instead of nesting StackPanel
s.
So why is depth more important than raw element count? Well, depth generally implies;
Concerning occlusion, the BitmapCache
class can help greatly!
Upvotes: 3
Reputation: 3515
When you create a very complex UI, with lots of nested objects and DataTemplate with lot of elements, you can impact seriously the performance of the App, because the bigger the UI Tree, the bigger it will take to render, and if the framework cannot render in 30FPS you will start to see performance drops. You should use the most lightweight panels you need in order to avoid extra logic you wonn't need. Here are some performance tips in order to make you App faster:
http://msdn.microsoft.com/en-us/library/bb613542(v=vs.110).aspx
Upvotes: 2