* 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
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 |
|
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]