The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GeometryDrawing.Geometry Property

Gets or sets the Geometry that describes the shape of this GeometryDrawing.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)

public Geometry Geometry { get; set; }

Property Value

Type: System.Windows.Media.Geometry
The shape described by this GeometryDrawing. The default value is null.

Identifier field


Metadata properties set to true


This example shows how to create and display a GeometryDrawing. A GeometryDrawing enables you to create shape with a fill and an outline by associating a Pen and a Brush with a Geometry. The Geometry describes the shape's structure, the Brush describes the shape's fill, and the Pen describes the shape's outline.

The following example uses a GeometryDrawing to render a shape. The shape is described by a GeometryGroup and two EllipseGeometry objects. The shape's interior is painted with a LinearGradientBrush and its outline is drawn with a Black Pen. The GeometryDrawing is displayed using an ImageDrawing and an Image element.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SDKSample
    public class GeometryDrawingExample : Page
        public GeometryDrawingExample()

            // Create the Geometry to draw. 
            GeometryGroup ellipses = new GeometryGroup();
                new EllipseGeometry(new Point(50,50), 45, 20)
                new EllipseGeometry(new Point(50, 50), 20, 45)

            // Create a GeometryDrawing. 
            GeometryDrawing aGeometryDrawing = new GeometryDrawing();
            aGeometryDrawing.Geometry = ellipses;

            // Paint the drawing with a gradient.
            aGeometryDrawing.Brush = 
                new LinearGradientBrush(
                    new Point(0,0), 
                    new Point(1,1));

            // Outline the drawing with a solid color.
            aGeometryDrawing.Pen = new Pen(Brushes.Black, 10);

            // Use a DrawingImage and an Image control 
            // to display the drawing. 
            DrawingImage geometryImage = new DrawingImage(aGeometryDrawing);

            // Freeze the DrawingImage for performance benefits.

            Image anImage = new Image();
            anImage.Source = geometryImage;
            anImage.Stretch = Stretch.None;
            anImage.HorizontalAlignment = HorizontalAlignment.Left;

            // Place the image inside a border and 
            // add it to the page. 
            Border exampleBorder = new Border();
            exampleBorder.Child = anImage;
            exampleBorder.BorderBrush = Brushes.Gray;
            exampleBorder.BorderThickness = new Thickness(1);
            exampleBorder.HorizontalAlignment = HorizontalAlignment.Left;
            exampleBorder.VerticalAlignment = VerticalAlignment.Top;
            exampleBorder.Margin = new Thickness(10);

            this.Margin = new Thickness(20);
            this.Background = Brushes.White;
            this.Content = exampleBorder;

  Margin="20" Background="White">

  <Border BorderBrush="Gray" BorderThickness="1" 
    HorizontalAlignment="Left" VerticalAlignment="Top"
    <Image Stretch="None" HorizontalAlignment="Left">
        <DrawingImage PresentationOptions:Freeze="True">


                <!-- Create a composite shape. -->
                  <EllipseGeometry Center="50,50" RadiusX="45" RadiusY="20" />
                  <EllipseGeometry Center="50,50" RadiusX="20" RadiusY="45" />

                <!-- Paint the drawing with a gradient. -->
                  <GradientStop Offset="0.0" Color="Blue" />
                  <GradientStop Offset="1.0" Color="#CCCCFF" />

                <!-- Outline the drawing with a solid color. -->
                <Pen Thickness="10" Brush="Black" />


The following illustration shows the resulting GeometryDrawing.

A GeometryDrawing of two ellipses

To create more complex drawings, you can combine multiple drawing objects into a single composite drawing using a DrawingGroup.

More Code

How to: Paint an Area with a DrawingThis example shows how to paint an area with a drawing. To paint an area with a drawing, you use a DrawingBrush and one or more Drawing objects. The following example uses a DrawingBrush to paint an object with a drawing of two ellipses.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft