--- title: "How to: Improve Rendering Performance by Caching an Element" ms.date: "03/30/2017" helpviewer_keywords: - "rendering performance [WPF], caching an element" - "BitmapCache [WPF], improving rendering performance" - "CacheMode [WPF], improving rendering performance" - "performance [WPF], caching an element" - "UIElement [WPF], caching" ms.assetid: 4739c1fc-60ba-4c46-aba6-f6c1a2688f19 --- # How to: Improve Rendering Performance by Caching an Element Use the class to improve rendering performance of a complex . To cache an element, create a new instance of the class and assign it to the element's property. You can reuse a efficiently in a . ## 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 with default values is assigned to the of the canvas, and an animation shows the smooth scaling of the cached bitmap. [!code-xaml[System.Windows.Media.BitmapCache#_BitmapCacheXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/system.windows.media.bitmapcache/cs/window1.xaml#_bitmapcachexaml)] ## See also - - - - [How to: Use a Cached Element as a Brush](how-to-use-a-cached-element-as-a-brush.md)