Pen.Brush Property

Gets or sets the fill the outline produced by this Pen.

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

member Brush : Brush with get, set

Property Value

Type: System.Windows.Media.Brush
The fill of the outline produced by this Pen. The default value is a null reference (Nothing in Visual Basic).

Identifier field

BrushProperty

Metadata properties set to true

None

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.

No code example is currently available or this language may not be supported.
<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

Outlines produces by a Pen

More Code

How to: Paint an Area with an ImageThis example shows how to use the ImageBrush class to paint an area with an image. An ImageBrush displays a single image, which is specified by its ImageSource property.

.NET Framework

Supported in: 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.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft