Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-paint-an-area-with-a-drawing.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

3.0 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Paint an Area with a Drawing 03/30/2017
csharp
vb
brushes [WPF], painting with drawings
painting [WPF], with drawings
drawings [WPF], painting with
c10dc4b1-09b1-41e8-ad14-456b5fb377df

How to: Paint an Area with a Drawing

This example shows how to paint an area with a drawing. To paint an area with a drawing, you use a xref:System.Windows.Media.DrawingBrush and one or more xref:System.Windows.Media.Drawing objects. The following example uses a xref:System.Windows.Media.DrawingBrush to paint an object with a drawing of two ellipses.

Example

[!code-xamldrawingbrush_snip#DrawingBrushExampleWholePage]

[!code-csharpdrawingbrush_procedural_snip#DrawingBrushExampleWholePage] [!code-vbdrawingbrush_procedural_snip#DrawingBrushExampleWholePage]

The following illustration shows the example's output.

Output from a DrawingBrush

(The center of the shape is white for reasons described in Control the Fill of a Composite Shape.)

By setting a xref:System.Windows.Media.DrawingBrush object's xref:System.Windows.Media.TileBrush.Viewport%2A and xref:System.Windows.Media.TileBrush.TileMode%2A properties, you can create a repeating pattern. The following example paints an object with a pattern created from a drawing of two ellipses.

[!code-xamldrawingbrush_snip#TiledDrawingBrushExampleWholePage]

[!code-csharpdrawingbrush_procedural_snip#TiledDrawingBrushExampleWholePage] [!code-vbdrawingbrush_procedural_snip#TiledDrawingBrushExampleWholePage]

The following illustration shows the tiled xref:System.Windows.Media.DrawingBrush output.

Tiled output from a DrawingBrush

For more information about drawing brushes, see Painting with Images, Drawings, and Visuals. For more information about xref:System.Windows.Media.Drawing objects, see the Drawing Objects Overview.