How to speed up WPF programs?

I love programming with and for Windows Presentation Framework. Mostly I write browser-like apps using WPF and XAML.

But what really annoys me is the slowness of WPF. A simple page with only a few controls loads fast enough, but as soon as a page is a teeny weeny bit more complex, like containing a lot of data entry fields, one or two tab controls, and stuff, it gets painful.

Loading of such a page can take more than one second. Seconds, indeed, especially on not so fast computers (read: the customers computers) it can take ages.

Same with changing values on the page. Everything about the WPF UI is somehow sluggy.

This is so mean! They give me this beautiful framework, but make it so excruciatingly slow so I'll have to apologize to our customers all the time!

My Question:

  1. How do you speed up WPF?
  2. How do you profile bottlenecks?
  3. How do you deal with the slowness?

Since this seems to be an universal problem with WPF, I'm looking for general advice, useful for many situations and problems.

Some other related questions:

  • What tools do you use for WPF development
  • Tools to develop WPF or Silverlight applications

Solution 1:

  1. How do you speed up WPF?

    Often after using one of the following profiling tools it is obvious what is causing my bottlenecks.

    • If memory is the issue then I virtualize my data.
    • If render time is the issue then I virtualize the controls or simplify control templates where possible.
    • If processing time is the issue I try to improve my algorithm or move that work to a background thread and show a throbber in my ui while the work is going.

  2. How do you profile bottlenecks?

    • .NET Memory Pofiler
    • dotTrace
    • Performance Profiling Tools for WPF
    • Snoop
    • Crack.NET

  3. How do you deal with the slowness?

    Profiling and counseling.

Solution 2:

Install SP1... Loads of very cool performance increases for WPF!!!

Read more here

Here is a example of 2 enhanchements made in SP1: Deffered scrolling & UI Element recyceling!!!