This documentation is archived and is not being maintained.
GeometryDrawing::Pen Property
Visual Studio 2010
Gets or sets the Pen used to stroke this GeometryDrawing.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
<object> <object.Pen> <Pen .../> </object.Pen> </object>
Property Value
Type: System.Windows.Media::PenThe pen used to stroke this GeometryDrawing. The default value is nullptr.
This example shows how use a Pen to outline a shape. To create a simple Pen, you need only specify its Thickness and Brush. You can create more complex pen's by specifying a DashStyle, DashCap, LineJoin, StartLineCap, and EndLineCap.
The following example uses a Pen to outline a shape defined by a GeometryDrawing.
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="White"> <Image Stretch="None" Margin="20"> <Image.Source> <DrawingImage> <DrawingImage.Drawing> <DrawingGroup> <GeometryDrawing> <GeometryDrawing.Geometry> <GeometryGroup> <RectangleGeometry Rect="0,0,50,50" /> <EllipseGeometry Center="75,75" RadiusX="50" RadiusY="50" /> <LineGeometry StartPoint="75,75" EndPoint="75,0" /> </GeometryGroup> </GeometryDrawing.Geometry> <GeometryDrawing.Pen> <Pen Thickness="10" LineJoin="Round" EndLineCap="Triangle" StartLineCap="Round"> <Pen.Brush> <LinearGradientBrush> <GradientStop Offset="0.0" Color="#CCCCFF" /> <GradientStop Offset="1.0" Color="Purple" /> </LinearGradientBrush> </Pen.Brush> </Pen> </GeometryDrawing.Pen> </GeometryDrawing> </DrawingGroup> </DrawingImage.Drawing> </DrawingImage> </Image.Source> </Image> </Page>
A GeometryDrawing

More Code
| How to: Create a GeometryDrawing | 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. |
| 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 DrawingBrush and one or more Drawing objects. The following example uses a DrawingBrush to paint an object with a drawing of two ellipses. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: