Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-composite-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.5 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Create a Composite Drawing 03/30/2017
drawings [WPF], composite
composite drawings [WPF]
graphics [WPF], composite drawings
066eb0ab-5f0e-439d-85c6-dca60af269fc

How to: Create a Composite Drawing

This example shows how to use a xref:System.Windows.Media.DrawingGroup to create complex drawings by combining multiple xref:System.Windows.Media.Drawing objects into a single composite drawing.

Example

The following example uses a xref:System.Windows.Media.DrawingGroup to create a composite drawing from the xref:System.Windows.Media.GeometryDrawing and xref:System.Windows.Media.ImageDrawing objects. The following illustration shows the output that this example produces.

A DrawingGroup with multiple drawings
A composite drawing that is created by using DrawingGroup

Note the gray border, which shows the bounds of the drawing.

[!code-csharpDrawingMiscSnippets_snip#GraphicsMMSimpleDrawingGroupExample] [!code-xamlDrawingMiscSnippets_snip#GraphicsMMSimpleDrawingGroupExample]

You can use a xref:System.Windows.Media.DrawingGroup to apply a xref:System.Windows.Media.DrawingGroup.Transform%2A, xref:System.Windows.Media.DrawingGroup.Opacity%2A setting, xref:System.Windows.Media.DrawingGroup.OpacityMask%2A, xref:System.Windows.Media.DrawingGroup.BitmapEffect%2A, xref:System.Windows.Media.DrawingGroup.ClipGeometry%2A, or xref:System.Windows.Media.DrawingGroup.GuidelineSet%2A to the drawings it contains. Because a xref:System.Windows.Media.DrawingGroup is also a xref:System.Windows.Media.Drawing, it can contain other xref:System.Windows.Media.DrawingGroup objects.

The following example is similar to the preceding example, except that it uses additional xref:System.Windows.Media.DrawingGroup objects to apply bitmap effects and an opacity mask to some of its drawings. The following illustration shows the output that this example produces.

A DrawingGroup with multiple drawings
Composite drawing that has multiple DrawingGroup objects

Note the gray border, which shows the bounds of the drawing.

[!code-csharpDrawingMiscSnippets_snip#GraphicsMMMultipleDrawingGroupsExample] [!code-xamlDrawingMiscSnippets_snip#GraphicsMMMultipleDrawingGroupsExample]

For more information about xref:System.Windows.Media.Drawing objects, see Drawing Objects Overview.

See also