Virtualized WPF Canvas


As you may already know WPF has a built-in virtualizing panel called VirtualizingStackPanel that supports UI virtualization and lays out its elements like StackPanel.

The WPF ListBox & ListView controls use this panel by default. Other containers controls such as Canvas do not have virtualization support in .Net 3.0 & 3.5.

Chris Lovett from Microsoft now wrote a great sample that shows how you can also virtualize a Canvas container control so it can efficiently host and scroll thousands of WPF elements without consuming huge amount of memory.  

The provided down-loadable ZIP has a white paper and the code.

Hope you find this useful.

Jossef.

VirtualCanvas.zip

Comments (10)

  1. WPF nous fournit par défaut un ‘VirtualizingStackPanel’ qui nous permet de virtualiser les éléments graphiques

  2. We sometimes hear concerns that WPF applications memory foot print is too large. This could be because

  3. Возможности WPF по виртуализации визуального дерева вашего интерфейса.

  4. RomanLerman says:

    It’s great control. But when it shows grid with many items, scrolling is very slow. How can it be improved?  

    Sorry for my English.

  5. corne_kruger@hotmail.com says:

    This works GREAT!!! But was wondering how I would go about adding items to it when it is used to override a Listbox’s Style like this:

    <Style TargetType="{x:Type ListBox}">

       <Setter Property="ItemsPanel">

            <Setter.Value>

                 <ItemsPanelTemplate>

                      <VirtualCanvas Background="Transparent"/>

                 </ItemsPanelTemplate>

            </Setter.Value>

       </Setter>

    </Style>

  6. dpruitt says:

    What is the license on this code?

  7. Jossef says:

    Hi dpruitt , you are welcome to use the provided code in your application. Be aware though that it was not thoroughly tested.  

    Jossef.

  8. Rajagopal R says:

    Its a great control. Do you have a same in Silverlight? else How to convert it into "Silverlight"?

  9. KarthiK.K.K says:

    Its great one. Can you please tell me how to do zooming the panning in this control?, or is there any other control to do this?

Skip to main content