Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CornerRadius structure

Applies to Windows and Windows Phone

Describes the characteristics of a rounded corner, such as can be applied to a Border.

Syntax


public struct CornerRadius


<CornerRadius>uniformRadius</CornerRadius>
-or-
<CornerRadius>topLeft,topRight,bottomRight,bottomLeft</CornerRadius>


<object property="uniformRadius"/>
- or -
<object property="topLeft,topRight,bottomRight,bottomLeft"/>

XAML Values

uniformRadius

A value that specifies a uniform radius. The uniformRadius value is applied to all four CornerRadius values (BottomLeft, TopLeft, TopRight, BottomRight).

topLeft

Sets the initial TopLeft.

topRight

Sets the initial TopRight.

bottomRight

Sets the initial BottomRight.

bottomLeft

Sets the initial BottomLeft.

Attributes

[Version(0x06020000)]
[WebHostHidden()]

Members

The CornerRadius structure has these types of members:

Constructors

The CornerRadius structure has these constructors.

ConstructorDescription
CornerRadius(Double) Initializes a new CornerRadius structure, applying the same uniform radius to all its corners.
CornerRadius(Double, Double, Double, Double) Initializes a new CornerRadius structure, applying the same uniform radius to all its corners.

 

Fields

The CornerRadius structure has these fields.

FieldData typeDescription
BottomLeft

System.Double [.NET] | float64 [C++]

The radius of rounding, in pixels, of the lower-left corner of the object where a CornerRadius is applied.

BottomRight

System.Double [.NET] | float64 [C++]

The radius of rounding, in pixels, of the lower-right corner of the object where a CornerRadius is applied.

TopLeft

System.Double [.NET] | float64 [C++]

The radius of rounding, in pixels, of the upper-left corner of the object where a CornerRadius is applied.

TopRight

System.Double [.NET] | float64 [C++]

The radius of rounding, in pixels, of the upper-right corner of the object where a CornerRadius is applied.

 

Methods

The CornerRadius structure has these methods. It also inherits methods from the Object class.

MethodDescription
Equals(CornerRadius) [C#, VB]Compares two CornerRadius structures for equality.
Equals(Object) [C#, VB]Determines whether the specified object is equal to a CornerRadius.
GetHashCode [C#, VB]Gets a hash code for this object.
ToString [C#, VB]Converts a CornerRadius to a String representation.

 

Operators

The CornerRadius structure has these operators.

OperatorDescription
Equality Compares two CornerRadius structures for equality.
Inequality Compares two CornerRadius structures for inequality.

 

Properties

The CornerRadius structure has these properties.

PropertyAccess typeDescription

BottomLeft

Read/writeGets or sets the radius of rounding, in pixels, of the bottom left corner of the object where a CornerRadius is applied.

BottomRight

Read/writeGets or sets the radius of rounding, in pixels, of the bottom right corner of the object where a CornerRadius is applied.

TopLeft

Read/writeGets or sets the radius of rounding, in pixels, of the top left corner of the object where a CornerRadius is applied.

TopRight

Read/writeGets or sets the radius of rounding, in pixels, of the top right corner of the object where a CornerRadius is applied.

 

Remarks

Notes on XAML syntax

Although you can specify a CornerRadius as an object element, you cannot specify the individual values such as BottomLeft as attributes of that object element. The XAML parser does not support setting XAML attribute values for this structure. Instead, you must specify the values as initialization text within the CornerRadius. Using the object element syntax for a CornerRadius is useful if you want to declare a keyed resource that can be used by multiple Border instances for their Border.CornerRadius. For more info on XAML initialization text, see Basic XAML syntax guide.

If you specify an attribute string or initialization text with two or three values, only the first value is respected and is treated as the uniformRadius (the other values are ignored). You must specify all four values to use a different behavior than uniformRadius.

You can use a space rather than a comma as the delimiter between values.

Projection and members of CornerRadius

If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or in Visual C++ component extensions (C++/CX), then CornerRadius has non-data members available, and its data members are exposed as read-write properties, not fields.

If you are programming with C++ using the Windows Runtime Template Library (WRL), then only the data member fields exist as members of CornerRadius, and you cannot use the utility methods or properties listed in the members table. WRL code can access similar utility methods that exist on the CornerRadiusHelper class.

Examples

This XAML example shows several styles of Border using different CornerRadius values:


    <StackPanel>
        <Border Height="30" Width="200" CornerRadius="0" 
         BorderThickness="2" BorderBrush="Red" Margin="5">
            <TextBlock>CornerRadius: 0</TextBlock>
        </Border>
        <Border Height="30" Width="200" CornerRadius="5" 
         BorderThickness="2" BorderBrush="Red" Margin="5">
            <TextBlock>CornerRadius: 5</TextBlock>
        </Border>
        <Border Height="30" Width="200" CornerRadius="5,0,5,0" 
         BorderThickness="2" BorderBrush="Red" Margin="5">
            <TextBlock>CornerRadius: 5,0,5,0</TextBlock>
        </Border>
        <Border Height="30" Width="200" CornerRadius="5,5,0,0" 
         BorderThickness="2" BorderBrush="Red" Margin="5">
            <TextBlock>CornerRadius: 5,5,0,0</TextBlock>
        </Border>
    </StackPanel>

The XAML produces this rendered output:

rendered output of CornerRadius XAML example

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

Assembly

System.Runtime.WindowsRuntime.UI.Xaml.dll

 

 

Show:
© 2014 Microsoft