WPF Perf, Element Count, Panels and Controls

Published 02 May 06 09:35 AM | henryh 

I got a question about WPF performance this morning regarding how the number of elements (controls, panels, et al.) affects performance.  Before I share more broadly, I'll mention that the WPF Performance team is working on plans for more detailed & prescriptive guidance; you should stay tuned here & MSDN for more info.  In the mean time, here's the response I provided:

--------

There is a cost for additional elements that you add; to name a few: 

  1. Working set – you’ve got more elements and more state that consumes memory.
  2. Layout – you’re performing more layout work even if these are fairly simple calls.
  3. Property invalidations – when a property changes there’s more work to update affected values.
  4. Hit testing – more elements to check when input is received.

One of the key ways to improve performance of your app is to reduce the number of elements.  You can do this in a variety of ways: 

  • Use virtualization when you can in ItemsControls using the VirtualizingStackPanel.
  • Use the Grid element as a top‑most layout when you have a fairly complex & nested layout instead of several panels.
  • Reduce the number of elements in and depth of templates when you can.

Comments

# Henry Hahn WPF Perf Element Count Panels and Controls | Outdoor Ceiling Fans said on May 31, 2009 3:32 AM:

PingBack from http://outdoorceilingfansite.info/story.php?id=4253

Anonymous comments are disabled

About henryh

Henry works in the .Net Developer Platform group at Microsoft.

Search

This Blog

Tags

Syndication

Page view tracker