--- title: "How to: Paint an Area with a Visual" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "painting [WPF]" - "visuals [WPF], painting with" - "brushes [WPF], painting with visuals" ms.assetid: 35f92996-1d03-4542-acc4-3469dcf09492 --- # How to: Paint an Area with a Visual This example shows how to use the class to paint an area with a . In the following example, several controls and a panel are used as the background of a rectangle. ## Example [!code-xaml[BrushOverviewExamples_snip#GraphicsMMVisualBrushAsRectangleBackgroundExample](~/samples/snippets/xaml/VS_Snippets_Wpf/BrushOverviewExamples_snip/XAML/VisualBrushExample.xaml#graphicsmmvisualbrushasrectanglebackgroundexample)] [!code-csharp[BrushOverviewExamples_procedural_snip#GraphicsMMVisualBrushAsRectangleBackgroundExample1](~/samples/snippets/csharp/VS_Snippets_Wpf/BrushOverviewExamples_procedural_snip/CSharp/VisualBrushExample.cs#graphicsmmvisualbrushasrectanglebackgroundexample1)] [!code-vb[BrushOverviewExamples_procedural_snip#GraphicsMMVisualBrushAsRectangleBackgroundExample1](~/samples/snippets/visualbasic/VS_Snippets_Wpf/BrushOverviewExamples_procedural_snip/visualbasic/visualbrushexample.vb#graphicsmmvisualbrushasrectanglebackgroundexample1)] For more information about and additional examples, see the [Painting with Images, Drawings, and Visuals](painting-with-images-drawings-and-visuals.md) overview. This code example is part of a larger example provided for the class. For the complete sample, see the [VisualBrush Sample](https://github.com/Microsoft/WPF-Samples/tree/master/Graphics/VisualBrush). ## See also - [Painting with Images, Drawings, and Visuals](painting-with-images-drawings-and-visuals.md)