This documentation is archived and is not being maintained.

RectangleGeometry.RadiusX Property

Gets or sets the x-radius of the ellipse use to round the corners of the rectangle.

Namespace: System.Windows.Media
Assembly: PresentationCore (in presentationcore.dll)
XML Namespace:

public double RadiusX { get; set; }
/** @property */
public double get_RadiusX ()

/** @property */
public void set_RadiusX (double value)

public function get RadiusX () : double

public function set RadiusX (value : double)

<object RadiusX="double" .../>

Property Value

A value greater than or equal to zero and less than or equal to half the rectangle's width that describes the x-radius of the ellipse use to round the corners of the rectangle. Values greater than half the rectangle's width are treated as though equal to half the rectangle's width. Negative values are treated as positive values. The default is 0.0.

For the rectangle to have rounded corners, both the RadiusX and RadiusY properties must be non-zero.

To round the corners of a RectangleGeometry, set its RadiusX and RadiusY properties to a value greater than zero. The larger the values, the rounder the rectangle's corners.

The following example shows several RectangleGeometry objects with different RadiusX and RadiusY settings. The RectangleGeometry objects are displayed using Path elements.


    <!-- Create a grid background to highlight the
         coordinate system. -->
    <DrawingBrush x:Key="GridDrawingBrushResource" 
      ViewportUnits="Absolute" TileMode="Tile">
            <GeometryDrawing Brush="White">
                <RectangleGeometry Rect="0,0,1,1" />
            <GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="#CCCCFF" />
            <GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="#CCCCFF" />

    <!-- Create a graph paper style border to frame the rectangles. -->
    <Style x:Key="GraphPaperBorderStyle" TargetType="{x:Type Border}">
      <Setter Property="HorizontalAlignment" Value="Left" />
      <Setter Property="Background" 
        Value="{StaticResource GridDrawingBrushResource}" />
      <Setter Property="BorderBrush" Value="Black" />
      <Setter Property="BorderThickness" Value="1" />
      <Setter Property="Margin" Value="10" />
      <Setter Property="Width" Value="190" />
      <Setter Property="Height" Value="90" />

  <StackPanel Name="MainStackPanel">

    <Border Style="{StaticResource GraphPaperBorderStyle}">
      <Path Stroke="Black" 

          <!-- Create a rectangle without rounded corners.  -->
            Rect="20,20,150,50"  />

    <Border Style="{StaticResource GraphPaperBorderStyle}">
      <Path Stroke="Black" 

          <!-- Create a rectangle with rounded corners
             by giving the RectangleGeometry a RadiusX
             and a RadiusY of 10.  -->
            Rect="20,20,150,50" RadiusX="10" RadiusY="10" />

    <Border Style="{StaticResource GraphPaperBorderStyle}" >
      <Path Stroke="Black" 

          <!-- Set RadiusX and RadiusY to their maximum values 
             (half the rectangle's width and 
              half the rectangle's height).  -->
            Rect="20,20,150,50" RadiusX="75" RadiusY="25"  />


Rectangles with Rounded Corners

Rectangles with different RadiusX/RadiusY settings

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0