-api-id | -api-type |
---|---|
T:Microsoft.UI.Xaml.Shapes.Rectangle |
winrt class |
Draws a rectangle with a given Height and Width specified in device-independent pixel (DIP).
<Rectangle .../>
You can set the Fill property to give the shape a background fill, like a solid color, gradient, or image. You can set the Stroke and other related stroke properties to specify the look of the shape's outline.
This example shows how to create a Rectangle in XAML and set some of its common properties as attribute values.
<Canvas>
<Rectangle Width="100" Height="100" Fill="Blue" Stroke="Red"
Canvas.Top="20" Canvas.Left="20" StrokeThickness="3" />
</Canvas>
Tip
For more info, design guidance, and code examples, see Draw shapes.
[!div class="nextstepaction"] Open the WinUI 3 Gallery app and see Shape features in action.
The WinUI 3 Gallery app includes interactive examples of most WinUI 3 controls, features, and functionality. Get the app from the Microsoft Store or get the source code on GitHub