--- title: "How to: Use a Cached Element as a Brush" ms.date: "03/30/2017" helpviewer_keywords: - "BitmapCache [WPF], using" - "cached element [WPF], use as a brush" - "BitmapCacheBrush [WPF], using" - "CacheMode [WPF], using" ms.assetid: d36e944a-866e-4baf-98c4-fd6a75f6fdd0 --- # How to: Use a Cached Element as a Brush Use the class to reuse a cached element efficiently. To cache an element, create a new instance of the class and assign it to the element's property. ## Example The following code example shows how to reuse a cached element. The cached element is an control that displays a large image. The control is cached as a bitmap by using the class, and the cache is reused by assigning it to a . The brush is assigned to the background of twenty-five buttons to show efficient reuse. [!code-xaml[System.Windows.Media.BitmapCacheBrush#_BitmapCacheBrushXAML](~/samples/snippets/csharp/VS_Snippets_Wpf/system.windows.media.bitmapcachebrush/cs/window1.xaml#_bitmapcachebrushxaml)] ## See also - - - - [How to: Improve Rendering Performance by Caching an Element](how-to-improve-rendering-performance-by-caching-an-element.md)