* 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.5 KiB
title, ms.date, helpviewer_keywords, ms.assetid
| title | ms.date | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|
| How to: Use a Cached Element as a Brush | 03/30/2017 |
|
d36e944a-866e-4baf-98c4-fd6a75f6fdd0 |
How to: Use a Cached Element as a Brush
Use the xref:System.Windows.Media.BitmapCacheBrush class to reuse a cached element efficiently. 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.
Example
The following code example shows how to reuse a cached element. The cached element is an xref:System.Windows.Controls.Image control that displays a large image. The xref:System.Windows.Controls.Image control is cached as a bitmap by using the xref:System.Windows.Media.BitmapCache class, and the cache is reused by assigning it to a xref:System.Windows.Media.BitmapCacheBrush. The brush is assigned to the background of twenty-five buttons to show efficient reuse.
[!code-xamlSystem.Windows.Media.BitmapCacheBrush#_BitmapCacheBrushXAML]