--- title: "How to: Paint an Area with a Video" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "painting with a video [WPF]" - "video [WPF], painting with" - "brushes [WPF], painting with a video" ms.assetid: 04dd6600-4a6e-4b43-a93e-21cce7dfbcb8 --- # How to: Paint an Area with a Video This example shows how to paint an area with media. One way to paint an area with media is to use a together with a . Use the to load and play the media, and then use it to set the property of the . You can then use the to paint an area with the loaded media. ## Example The following example uses a and a to paint the of a control with video. This example sets the property of the to `true` so that it produces no sound. [!code-csharp[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundInline](~/samples/snippets/csharp/VS_Snippets_Wpf/visualbrush_markup_snip/CSharp/PaintWithVideoExample.cs#graphicsmmvideoastextbackgroundinline)] [!code-vb[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundInline](~/samples/snippets/visualbasic/VS_Snippets_Wpf/visualbrush_markup_snip/visualbasic/paintwithvideoexample.vb#graphicsmmvideoastextbackgroundinline)] [!code-xaml[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundInline](~/samples/snippets/xaml/VS_Snippets_Wpf/visualbrush_markup_snip/XAML/PaintWithVideoExample.xaml#graphicsmmvideoastextbackgroundinline)] ## Example Because inherits from the class, it provides several tiling modes. By setting the property of a to and by setting its property to a value smaller than the area that you are painting, you can create a tiled pattern. The following example is identical to the previous example, except that the generates a pattern from the video. [!code-csharp[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundTiledInline](~/samples/snippets/csharp/VS_Snippets_Wpf/visualbrush_markup_snip/CSharp/PaintWithVideoExample.cs#graphicsmmvideoastextbackgroundtiledinline)] [!code-vb[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundTiledInline](~/samples/snippets/visualbasic/VS_Snippets_Wpf/visualbrush_markup_snip/visualbasic/paintwithvideoexample.vb#graphicsmmvideoastextbackgroundtiledinline)] [!code-xaml[Visualbrush_markup_snip#GraphicsMMVideoAsTextBackgroundTiledInline](~/samples/snippets/xaml/VS_Snippets_Wpf/visualbrush_markup_snip/XAML/PaintWithVideoExample.xaml#graphicsmmvideoastextbackgroundtiledinline)] For information about how to add a content file, such as a media file, to your application, see [WPF Application Resource, Content, and Data Files](../app-development/wpf-application-resource-content-and-data-files.md). When you add a media file, you must add it as a content file, not as a resource file. ## See also - - [Painting with Images, Drawings, and Visuals](painting-with-images-drawings-and-visuals.md) - [TileBrush Overview](tilebrush-overview.md) - [Multimedia Overview](multimedia-overview.md)