You don't need to explicitly declare the points such that the start point and end point are both specified as the same Point value. In code-behind you use a PointCollection to define the points and you add each individual point as a Point value to the collection. In XAML, you define the points with a comma-separated list. The Points property defines the collection of points that make up the boundary. The boundary is created by connecting a line from one point to the next, with the last point connected to the first point. PolygonĪ Polygon is a shape with a boundary defined by an arbitrary number of points. Whenever the control is in a "Focused" visual state, this rectangle is made visible, in other states it's hidden. A Rectangle shape is seen in many control templates because it's used as a "FocusVisual" part for focusable controls. On the other hand, a Rectangle is probably a better choice for control composition. A Border also has the option of having rounded corners if you set the CornerRadius property. If your intention is to create a rectangle shape around other content, it might be better to use Border because it can have child content and will automatically size around that content, rather than using the fixed dimensions for height and width like Rectangle does. Tip There are some scenarios for UI definitions where instead of using a Rectangle, a Border might be more appropriate. Rectangle1.Stroke = new SolidColorBrush(Windows.UI.Colors.Black) Rectangle1.Fill = new SolidColorBrush(Windows.UI.Colors.Blue) We set the RadiusX property to 50 and the RadiusY property to 10, which gives the Rectangle rounded corners. It uses a Blue value of SolidColorBrush for its Fill and a Black value of SolidColorBrush for its Stroke. The next example creates a Rectangle with a Width of 200 and a Height of 100. The maximum allowed value of RadiusX is the Width divided by two and the maximum allowed value of RadiusY is the Height divided by two. These properties specify the x-axis and y-axis of an ellipse that defines the curve of the corners. To create rounded corners, specify a value for the RadiusX and RadiusY properties. You can round the corners of a Rectangle. To create a basic Rectangle, specify a Width, a Height, and a Fill. RectangleĪ Rectangle is a four-sided shape with its opposite sides being equal. When an Ellipse is positioned in a UI layout, its size is assumed to be the same as a rectangle with that Width and Height the area outside the perimeter does not have rendering but still is part of its layout slot size.Ī set of 6 Ellipse elements are part of the control template for the ProgressRing control, and 2 concentric Ellipse elements are part of a RadioButton. In this case the Ellipse is what most people would consider a circle, but that's how you declare a circle shape in XAML: use an Ellipse with equal Width and Height. a panel named 'layoutRoot' in your XAML file, like this: When you create a XAML element in code, you have to add Įllipse1.Fill = new SolidColorBrush(Windows.UI.Colors.SteelBlue) The next example creates an Ellipse with a Width of 200 and a Height of 200, and uses a SteelBlue colored SolidColorBrush as its Fill. To create a basic Ellipse, specify a Width, Height, and a Brush for the Fill. EllipseĪn Ellipse is a shape with a curved perimeter. If you don't specify a Brush value for Stroke, or if you set StrokeThickness to 0, then the border around the shape is not drawn. StrokeThickness is a property that defines the perimeter's thickness around the shape edge. A Stroke also requires a Brush that defines its appearance, and should have a non-zero value for StrokeThickness. For more info about brushes, see Using brushes.Ī Shape can also have a Stroke, which is a line that is drawn around the shape's perimeter. Set the Fill property of the Shape to the Brush you want. UWP APIs: Path class, Windows.UI.Xaml.Shapes namespace, Windows.UI.Xaml.Media namespaceįor a Shape to render to the app canvas, you must associate a Brush with it.
0 Comments
Leave a Reply. |