CornerRadius CornerRadius CornerRadius Struct

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

Syntax

Declaration

public struct CornerRadiuspublic struct CornerRadiusPublic Structure CornerRadius
<CornerRadius>uniformRadius</CornerRadius>
-or-
<CornerRadius>topLeft,topRight,bottomRight,bottomLeft</CornerRadius>

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 CornerRadius. For more info on XAML initialization text, see 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

Fields summary

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

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

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

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

Fields

  • BottomLeft
    BottomLeft
    BottomLeft
    BottomLeft

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

    public field double BottomLeftpublic field double BottomLeftPublic Field BottomLeftpublic field double BottomLeft
  • BottomRight
    BottomRight
    BottomRight
    BottomRight

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

    public field double BottomRightpublic field double BottomRightPublic Field BottomRightpublic field double BottomRight
  • TopLeft
    TopLeft
    TopLeft
    TopLeft

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

    public field double TopLeftpublic field double TopLeftPublic Field TopLeftpublic field double TopLeft
  • TopRight
    TopRight
    TopRight
    TopRight

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

    public field double TopRightpublic field double TopRightPublic Field TopRightpublic field double TopRight

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.dll