Export (0) Print
Expand All

StreamGeometryContext.PolyLineTo Method

Draws one or more connected straight lines.

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

public abstract void PolyLineTo(
	IList<Point> points,
	bool isStroked,
	bool isSmoothJoin


Type: System.Collections.Generic.IList<Point>

The collection of points that specify destination points for one or more connected straight lines.

Type: System.Boolean

true to make the segment stroked when a Pen is used to render the segment; otherwise, false.

Type: System.Boolean

true to treat the join between this segment and the previous segment as a corner when stroked with a Pen; otherwise, false.


An attempt was made to add a segment without starting a figure by calling the BeginFigure method.

This method uses the end point of the previous segment as its starting point. If this is the first segment in a figure, it uses the point specified by the BeginFigure method as its start point.

A StreamGeometry cannot be serialized if it contains a Transform or any non-stroked or unfilled segments.

The following example shows how to draw a triangle using the PolyLineTo method.

using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace SDKSample
    public partial class StreamGeometryPolyLineToExample : Page
        public StreamGeometryPolyLineToExample()
            // Create a path to draw a geometry with.
            Path myPath = new Path();
            myPath.Stroke = Brushes.Black;
            myPath.StrokeThickness = 1;

            // Create a StreamGeometry to use to specify myPath.
            StreamGeometry geometry = new StreamGeometry();

            // Open a StreamGeometryContext that can be used to describe this StreamGeometry  
            // object's contents.  
            using (StreamGeometryContext ctx = geometry.Open())
                // Begin the triangle at the point specified.
                ctx.BeginFigure(new Point(10, 100), true /* is filled */, true /* is closed */);

                // Create a collection of Point structures that will be used with the PolyLineTo  
                // Method to create a triangle.
                List<Point> pointList = new List<Point>();

                // Two Points are added to the collection. The PolyLineTo method will draw lines 
                // between the Points of the collection.
                pointList.Add(new Point(100, 100));
                pointList.Add(new Point(100, 50));

                // Create a triangle using the collection of Point Structures.
                ctx.PolyLineTo(pointList, true /* is stroked */, false /* is smooth join */);


            // Freeze the geometry (make it unmodifiable) 
            // for additional performance benefits.

            // specify the shape (triangle) of the path using the StreamGeometry.
            myPath.Data = geometry;

            // Add path shape to the UI.
            StackPanel mainPanel = new StackPanel();
            this.Content = mainPanel;

.NET Framework

Supported in: 4.6, 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