Diese Dokumentation wurde archiviert und wird nicht länger gepflegt.


Represents the geometry of a circle or ellipse.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
XML-Namespaces:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public sealed class EllipseGeometry : Geometry
public final class EllipseGeometry extends Geometry
public final class EllipseGeometry extends Geometry

Use the EllipseGeometry class with a Path element or a GeometryDrawing to draw an ellipse, or with the Clip property of a UIElement to define an elliptical clip region. The EllipseGeometry class also has many other uses. For more information about EllipseGeometry, see the Geometry Overview.

EllipseGeometry Compared to Ellipse

The Ellipse class has a Fill, Stroke, and other rendering properties that EllipseGeometry lacks. The Ellipse class is a FrameworkElement and therefore participates in the layout system; it can be used as the content of any element that supports UIElement children.

The EllipseGeometry class, on the other hand, simply defines the geometry of an ellipse, and cannot render itself. Because of its simplicity, it has a wider range of uses.

Freezable Features

An EllipseGeometry is a type of Freezable object and therefore can be frozen to improve performance. For information about Freezable features, such as freezing and cloning, see the Freezable Objects Overview.

The following example uses two EllipseGeometry objects to define the contents of a GeometryDrawing. This example produces the following output:

Two EllipseGeometry objects

A GeometryDrawing of two ellipses

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" />


Weiterer Code

How to: Create a Shape by Using a PathGeometry

This example shows how to create a shape using the PathGeometry class. PathGeometry objects are composed of one or more PathFigure objects; each PathFigure represents a different "figure" or shape. Each PathFigure is itself composed of one or more PathSegment objects, each representing a connected portion of the figure or shape. Segment types include LineSegment, ArcSegment, and BezierSegment.

How to: Animate an EllipseGeometry

This example shows how to animate a Geometry within a Path element. In the following example, a PointAnimation is used to animate the Center of an EllipseGeometry.

How to: Animate a Point by Using Key Frames

This example shows how to use the PointAnimationUsingKeyFrames class to animate a Point.

How to: Create a Composite Shape

This example shows how to create composite shapes using Geometry objects and display them using a Path element. In the following example, a LineGeometry, EllipseGeometry, and a RectangleGeometry are used with a GeometryGroup to create a composite shape. The geometries are then drawn using a Path element.

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Microsoft .NET Framework 3.0 wird unter Windows Vista, Microsoft Windows XP SP2 und Windows Server 2003 SP1 unterstützt.

.NET Framework

Unterstützt in: 3.0