Rectangle Rectangle Rectangle Class

Draws a rectangle with a given Height and Width specified in device-independent pixel (DIP).

Syntax

Declaration

public sealed class Rectanglepublic sealed class RectanglePublic NotInheritable Class Rectangle
<Rectangle .../>

Inheritance Hierarchy

Inherited Members

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Tag
Tag
Tag
, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Remarks

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.

Examples

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>

Constructors summary

Initializes a new instance of the Rectangle class.

Properties summary

Gets or sets the x-axis radius of the ellipse that is used to round the corners of the rectangle.

Identifies the RadiusX dependency property.

Gets or sets the y-axis radius of the ellipse that is used to round the corners of the rectangle.

Identifies the RadiusY dependency property.

Constructors

  • Rectangle()
    Rectangle()
    Rectangle()
    Rectangle()

    Initializes a new instance of the Rectangle class.

    public Rectangle()public Rectangle()Public Function Rectangle() As

Properties

  • RadiusX
    RadiusX
    RadiusX
    RadiusX

    Gets or sets the x-axis radius of the ellipse that is used to round the corners of the rectangle.

    public double RadiusX { get; set; }public double RadiusX { get; set; }Public ReadWrite Property RadiusX As double
    <Rectangle RadiusX="double"/>
    

    Property Value

    • double
      double
      double

      The x-axis radius of the ellipse that is used to round the corners of the rectangle.

  • RadiusXProperty
    RadiusXProperty
    RadiusXProperty
    RadiusXProperty

    Identifies the RadiusX dependency property.

    public static DependencyProperty RadiusXProperty { get; }public static DependencyProperty RadiusXProperty { get; }Public Static ReadOnly Property RadiusXProperty As DependencyProperty

    Property Value

  • RadiusY
    RadiusY
    RadiusY
    RadiusY

    Gets or sets the y-axis radius of the ellipse that is used to round the corners of the rectangle.

    public double RadiusY { get; set; }public double RadiusY { get; set; }Public ReadWrite Property RadiusY As double
    <Rectangle RadiusY="double"/>
    

    Property Value

    • double
      double
      double

      The y-axis radius of the ellipse that is used to round the corners of the rectangle. The default is 0.

  • RadiusYProperty
    RadiusYProperty
    RadiusYProperty
    RadiusYProperty

    Identifies the RadiusY dependency property.

    public static DependencyProperty RadiusYProperty { get; }public static DependencyProperty RadiusYProperty { get; }Public Static ReadOnly Property RadiusYProperty As DependencyProperty

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.WebHostHiddenAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.UI.Xaml.Shapes.dll