Files
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.3 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Create a Combined Geometry 03/30/2017
combining geometries [WPF]
graphics [WPF], combining geometries
geometries [WPF], combining
54c3277c-6b6e-4b25-91be-fda0bbc706b4

How to: Create a Combined Geometry

This example shows how to combine geometries. To combine two geometries, use a xref:System.Windows.Media.CombinedGeometry object. Set its xref:System.Windows.Media.CombinedGeometry.Geometry1%2A and xref:System.Windows.Media.CombinedGeometry.Geometry2%2A properties with the two geometries to combine, and set the xref:System.Windows.Media.CombinedGeometry.GeometryCombineMode%2A property, which determines how the geometries will be combined together, to Union, Intersect, Exclude, or Xor.

To create a composite geometry from two or more geometries, use a xref:System.Windows.Media.GeometryGroup.

Example

In the following example, a xref:System.Windows.Media.CombinedGeometry is defined with a geometry combine mode of Exclude. Both xref:System.Windows.Media.CombinedGeometry.Geometry1%2A and the xref:System.Windows.Media.CombinedGeometry.Geometry2%2A are defined as circles of the same radius, but with centers offset by 50.

[!code-xamlGeometrySample#21]

Results of the Exclude combine mode
Combined Geometry Exclude

In the following markup, a xref:System.Windows.Media.CombinedGeometry is defined with a combine mode of Intersect. Both xref:System.Windows.Media.CombinedGeometry.Geometry1%2A and the xref:System.Windows.Media.CombinedGeometry.Geometry2%2A are defined as circles of the same radius, but with centers offset by 50.

[!code-xamlGeometrySample#22]

Results of the Intersect combine mode
Combined Geometry Intersect

In the following markup, a xref:System.Windows.Media.CombinedGeometry is defined with a combine mode of Union. Both xref:System.Windows.Media.CombinedGeometry.Geometry1%2A and the xref:System.Windows.Media.CombinedGeometry.Geometry2%2A are defined as circles of the same radius, but with centers offset by 50.

[!code-xamlGeometrySample#23]

Results of the Union combine mode
Combined Geometry Union

In the following markup, a xref:System.Windows.Media.CombinedGeometry is defined with a combine mode of Xor. Both xref:System.Windows.Media.CombinedGeometry.Geometry1%2A and the xref:System.Windows.Media.CombinedGeometry.Geometry2%2A are defined as circles of the same radius, but with centers offset by 50.

[!code-xamlGeometrySample#24]

Results of the Xor combine mode
Combined Geometry Xor