This list with performance tips is collected from many sources, including my personal experience. It is supposed to evolve and grow in the future.
Basic performance tips, regarding your code
Silverlight Plug-in options
- Avoid Using Windowless Mode
- Use Transparent Background only when needed
Animations
- Always be aware of the frame-rate.
- Think about the frame-rate on per Animation bases. More about this here.
- Big moving elements are always CPU expensive (Due to big redrawn regions).
- Understand each animation how expensive is.
- Understand CompositionTarget.Rendering event and use it if possible.
- Storyboards and animations over big regions are very expensive. Try to minimize them.
- Do not allow layout pass while animation is running (unless this is what you need). This means not to animate properties that are related to the Layout system like Height, Width, Visibility, Alignments, Margins…
- Text Animations – By default, Silverlight optimizes text for readability. That’s why animating text is expensive. Unless we do one of the following.
- Set TextRenderingMode = RenderForAnimation
- If the text is static, we can replace it with Image of the text and animate the Image control.
Monitor the performance during development
- MaxFrameRate = 10.000
- EnableFrameRateCounter = true
- EnableRedrawRegions = true
- Use Process Explorer to monitor the CPU usage
Advanced tips
UI Caching
-
WriteableBitmap – more on this here.
-
GPU cache – more on this here.
Can be very useful when cached elements are being translated, scaled, rotated or blended using opacity. Also it will work better if the cached elements are Leaf nodes in the visual tree.
- Limitations: You can’t cache elements that have been:
- Projected using Plane/MatrixProjections
- Applied effect, including Pixel Shader.
- Applied opacity mask.
- Applied non-rectangular clipping.
In order to make this list more helpful – all comments are more than welcome.