CornerRadius Struct
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public value class CornerRadius
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
struct CornerRadius
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public struct CornerRadius
Public Structure CornerRadius
<CornerRadius>uniformRadius</CornerRadius>
-or-
<CornerRadius>topLeft,topRight,bottomRight,bottomLeft</CornerRadius>
- or -
<object property="uniformRadius"/>
- or -
<object property="topLeft,topRight,bottomRight,bottomLeft"/>
- Inheritance
-
CornerRadius
- Attributes
Windows requirements
Device family |
Windows 10 (introduced in 10.0.10240.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v1.0)
|
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](windows.ui.xaml/images/cornerradiusoutput.png?view=winrt-26100)
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. For example, this XAML does not work:
<!-- THIS DOES NOT WORK -->
<CornerRadius x:Key="CornerRadiusError" BottomLeft="20"/>
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 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.
This example shows how to use initialization text to set the values of a CornerRadius resource, and then apply the resource to a Border.
<Page.Resources>
<CornerRadius x:Key="CornerRadius4010">40,10,40,10</CornerRadius>
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Border BorderBrush="Blue" BorderThickness="2"
CornerRadius="{StaticResource CornerRadius4010}"/>
</Grid>
Projection and members of CornerRadius
If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or 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. See CornerRadius in the .NET API Browser.
If you are programming with C++/WinRT or the Windows Runtime C++ Template Library (WRL), then only the data member fields exist as members of CornerRadius, and you cannot use the utility methods or properties of the .NET projection. C++ code can access similar utility methods that exist on the CornerRadiusHelper class.
This table shows the equivalent methods available in .NET and C++.
.NET (CornerRadius) | C++ (CornerRadiusHelper) |
---|---|
CornerRadius(Double) | FromUniformRadius(Double) |
CornerRadius(Double, Double, Double, Double) | FromRadii(Double, Double, Double, Double) |
Fields
BottomLeft |
The radius of rounding, in pixels, of the lower-left corner of the object where a CornerRadius is applied. |
BottomRight |
The radius of rounding, in pixels, of the lower-right corner of the object where a CornerRadius is applied. |
TopLeft |
The radius of rounding, in pixels, of the upper-left corner of the object where a CornerRadius is applied. |
TopRight |
The radius of rounding, in pixels, of the upper-right corner of the object where a CornerRadius is applied. |