Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-improve-rendering-performance-by-caching-an-element.md
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.7 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Improve Rendering Performance by Caching an Element 03/30/2017
rendering performance [WPF], caching an element
BitmapCache [WPF], improving rendering performance
CacheMode [WPF], improving rendering performance
performance [WPF], caching an element
UIElement [WPF], caching
4739c1fc-60ba-4c46-aba6-f6c1a2688f19

How to: Improve Rendering Performance by Caching an Element

Use the xref:System.Windows.Media.BitmapCache class to improve rendering performance of a complex xref:System.Windows.UIElement. To cache an element, create a new instance of the xref:System.Windows.Media.BitmapCache class and assign it to the element's xref:System.Windows.UIElement.CacheMode%2A property. You can reuse a xref:System.Windows.Media.BitmapCache efficiently in a xref:System.Windows.Media.BitmapCacheBrush.

Example

The following code example shows how to create a complex element and cache it as a bitmap, which improves performance when the element is animated. The element is a canvas that holds shape geometries with many vertices. A xref:System.Windows.Media.BitmapCache with default values is assigned to the xref:System.Windows.UIElement.CacheMode%2A of the canvas, and an animation shows the smooth scaling of the cached bitmap.

[!code-xamlSystem.Windows.Media.BitmapCache#_BitmapCacheXAML]

See also