Condividi tramite


Points (PolyBezierSegment)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Sets the set of points that define a PolyBezierSegment object.

<object Points="pointSet"  .../>
object.Points = "pointSet"

Property Value

Type: string

A delimited string that represents the set of points that define the PolyBezierSegment object.

This property is write-only.

pointSet Grammar

X1,Y1 X2,Y2 X3,Y3[, X1*,Y1* X2*,Y2* X3*,Y3*]*

X1, Y1

A pair of double values that identifies the first control point of the first segment.

X2, Y2

A pair of double values that identifies the second control point of the first segment.

X3, Y3

A pair of double values that identifies the endpoint of the first segment.

[, X1*,Y1*,X2*,Y2*,X3*,Y3*]*

Subsequent pairs of double values that identify the first and second control points and endpoints of additional segments defined by this object.

  • The [] (bracket) characters are not literals; they indicate optional values. The asterisk (*) indicates that any number of the sequence of six doubles (three points) that define more segments is permitted after the initial X1,Y1X2,Y2X3,Y3.

  • The separator in this grammar can be either a space or a comma. You can use a mixture of spaces and commas as separators. The common convention is to use commas between the X and Y values and spaces between the points, and this is shown in the grammar.

  • Any odd number of double values in a Points value is illegal and will raise either a parser or a run-time error. The number of double values in the string must always be even so that it can be evaluated as x,y pairs that define a point.

Managed Equivalent

Points

Remarks

A set of points is defined through a string syntax, which is enabled by an underlying type converter. There is no object available in the object model for accessing the set of points as a collection. In either script or XAML, Points is write-only; attempting to get the value in script will result in a run-time GetValue error. You set the value by specifying a string. Without a collection object, there is no way to obtain a count in the object model. However, you could parse the string yourself and count separators, or otherwise get a count before you pass the string as input.

A single point (X,Y pair) is accepted by the type converter, but will not render anything because you have thus far defined only one control point. You need a minimum of three points to produce rendered output for a PolyBezierSegment. In order to render, the number of points in the point set must be divisible by 3 so that there are always two control points and one endpoint for each segment. If this is not the case, no segments render.

Example

The following example shows how to use a PolyBezierSegment to create a series of curves.

<Canvas
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  Width="500" Height="100">
      <Path Stroke="Black" StrokeThickness="1">
        <Path.Data>
          <PathGeometry>
            <PathGeometry.Figures>
              <PathFigureCollection>

                <!-- The StartPoint specifies the starting point of the first curve. -->
                <PathFigure StartPoint="10,100">
                  <PathFigure.Segments>
                    <PathSegmentCollection>

                      <!-- The PolyBezierSegment specifies two cubic Bezier curves.
                           The first curve is from 10,100 (start point specified above)
                           to 300,100 with a control point of 0,0 and another control
                           point of 200,0. The second curve is from 300,100 
                           (end of the last curve) to 600,100 with a control point of 300,0
                           and another control point of 400,0. -->
                      <PolyBezierSegment Points="0,0 200,0 300,100 300,0 400,0 600,100" />
                    </PathSegmentCollection>
                  </PathFigure.Segments>
                </PathFigure>
              </PathFigureCollection>
            </PathGeometry.Figures>
          </PathGeometry>
        </Path.Data>
      </Path>
</Canvas>

Applies To

PolyBezierSegment