Creating Shapes and Containers Using Shape Templates
5 min to read
This document describes how to define shapes in XAML using shape templates. The ShapeTemplate is the main element that contains shape description. The ContainerShapeTemplate is used to describe containers.
Arc - Defines an arc with the size and the direction.
Each segment provides the X and Y properties that define its relative coordinates within the shape border. X="0" Y="0" corresponds to the top-left corner of the shape border, X="1" Y="1" corresponds to the bottom-right corner. The Line and Arc segments are drawn from the point defined by the preceding segment's X and Y values to the point defined by their X and Y.
The arc segment's size is specified using the CreateSize method that accepts absolute width and height values as parameters. You can pass the shape's current width and height as the method's parameters using the W and H variables respectively. To create an arc with a fixed height or width, pass a static value instead of a variable. The code snippet below illustrates how to create an arc half the size of the shape.
You can specify shape parameters by adding the Parameter class instances to the ShapeTemplate.Parameters collection. End-users can transform the shape by dragging the yellow handles that visually represent parameters. Each parameter is characterized by its Parameter.Value property. The Parameter.Point property specifies the handle's coordinates using the CreatePoint method. Use the P variable to pass the current Parameter.Value to this method's parameters.
You can pass the parameter's value to the CreateSize method. The P0 variable corresponds to the first parameter within the ShapeTemplate.Parameters collection, the P1 corresponds to the second parameter and so on. The code snippet below illustrates how to use this parameter to allow an end-user to transform the shape by changing the Arc segment's size.