WPF UI Optimization: Freezable and Static Resources
Posted on Thursday, August 2, 2012
|
No Comments
I'm sure if you are maintaining or developing a WPF application, you would have (or would, sometime in the future) face performance issues when your application runs on machines that are just not good enough for it – read WinXP, RDC versions below 7.0, Citrix...
So if you are stuck with any of those, you would definitely face issues from your app running slow to even the mouse being held captive as flickering ensues.
This is the first tip in a series of tips that will follow: use frozen and static resources in your styles as much as possible. The only reason to use dynamic resources is if those resources are going to change at runtime or if the values of these resources can only be evaluated at runtime. For everything that won’t change and can be evaluated before the code actually runs, use static resources.
The reason behind this is simple. WPF stops monitoring these resources for changes and also stores them in the cache. Hence, there is a considerable improvement in performance. Tried and tested.