Creates and caches a bitmap representation of a UIElement.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Use the class to improve rendering performance of a complex UIElement. Create a and assign it to the CacheMode property of a UIElement to cache the element and its subtree as a bitmap in video memory. This is useful when you need to animate, translate, or scale a UIElement as quickly as possible. This approach enables a tradeoff between performance and visual quality while content is cached.
Use the BitmapCacheBrush class to efficiently reuse a cached element.
Set the RenderAtScale property to scale the bitmap cache. This is useful if an element will be zoomed, and you want the element to render more clearly than it would if the cache were simply generated at the element’s native resolution.
Set the SnapsToDevicePixels property when the cache displays content that requires pixel-alignment to render correctly, such as ClearType text. This property is ignored by the BitmapCacheBrush and Viewport2DVisual3D classes.
Caching a control does not affect mouse-over behavior, so mouse-over hit testing operates as if it the bitmap were a live control.
Cache regeneration occurs only when the structure of the UIElement or its subtree changes, or when the CacheMode settings change. Setting the RenderAtScale or EnableClearType properties causes cache regeneration. Changes to the parent visual tree of the cached UIElement, such as transforms, scales, opacities, and effects, do not affect the cache.
The cache functions when hardware acceleration is not available. In this case, the bitmap is rendered in software, and the maximum bitmap dimensions are 2048 x 2048.
The following XAML shows how to cache a Canvas element. For the complete code example, see How to: Improve Rendering Performance by Caching an Element.
<!-- //////////////////////////////////////////////////////////////// --> <!-- // The following XAML creates a BitmapCache with default // --> <!-- // properties and assigns it as the CacheMode for the canvas. // --> <!-- //////////////////////////////////////////////////////////////// --> <Canvas.CacheMode> <BitmapCache EnableClearType="False" RenderAtScale="1" SnapsToDevicePixels="False" /> </Canvas.CacheMode>
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2