CornerRadius 结构

定义

表示矩形的角的半径。Represents the radii of a rectangle's corners.

public value class CornerRadius : IEquatable<System::Windows::CornerRadius>
[System.ComponentModel.TypeConverter(typeof(System.Windows.CornerRadiusConverter))]
public struct CornerRadius : IEquatable<System.Windows.CornerRadius>
type CornerRadius = struct
Public Structure CornerRadius
Implements IEquatable(Of CornerRadius)
继承
CornerRadius
属性
实现

示例

下面的示例演示如何使用 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) 和代码设置 CornerRadius 属性的值。The following example shows how to set the value of the CornerRadius property by using 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) and code.

myBorder1 = new Border();
myBorder1.BorderBrush = Brushes.SlateBlue;
myBorder1.BorderThickness = new Thickness(5, 10, 15, 20);
myBorder1.Background = Brushes.AliceBlue;
myBorder1.Padding = new Thickness(5);
myBorder1.CornerRadius = new CornerRadius(15);
Dim myBorder1 As New Border()
myBorder1.BorderBrush = Brushes.SlateBlue
myBorder1.BorderThickness = New Thickness(5, 10, 15, 20)
myBorder1.Background = Brushes.AliceBlue
myBorder1.Padding = New Thickness(5)
myBorder1.CornerRadius = New CornerRadius(15)
<Border BorderBrush="SlateBlue" BorderThickness="5,10,15,20" Background="AliceBlue" Padding="5" CornerRadius="15">

注解

此类具有四个属性,TopLeftTopRightBottomLeftBottomRight,它们对应于矩形的各个角。This class has four properties, TopLeft, TopRight, BottomLeft, and BottomRight, corresponding to the individual corners of the rectangle. 每个都是 Double 结构,可以独立于其他结构进行设置。Each is a Double structure that can be set independently of the others.

半径不能为负数。The radii cannot be negative.

XAML 特性用法XAML Attribute Usage

<object property="TopLeft,TopRight,BottomRight,BottomLeft "/>  

-或--or-

<object property="AllCorners"/>  

XAML 值XAML Values

TopLeftTopLeft
Double 值,该值指定左上角的半径。Double value that specifies the radius of the top left corner.

右上TopRight
指定右上角 Double 值。Double value that specifies the top right corner.

BottomRightBottomRight
指定右下角 Double 值。Double value that specifies the bottom right corner.

BottomLeftBottomLeft
指定左下角 Double 值。Double value that specifies the bottom left corner.

AllCornersAllCorners
如果只指定了一个 Double 值,则该度量值将应用于 CornerRadius的所有TopLeft右上BottomRightBottomLeft角。If only a single Double value is specified, that measure is applied to ALL of the TopLeft, TopRight, BottomRight, and BottomLeft corners of the CornerRadius.

备注

指定为字符串时,值不需要显式包含小数点。Values need not include the decimal point explicitly when specified as a string. 当在代码中引用时,XAMLXAML 中提供的字符串 "1" 的计算结果为1.0 的值。The string "1" provided in XAMLXAML evaluates to a value of 1.0 when referenced in code.

构造函数

CornerRadius(Double)

使用为每个角或矩形指定的统一半径值初始化 CornerRadius 类的新实例。Initializes a new instance of the CornerRadius class with a specified uniform radius value for every corner or the rectangle.

CornerRadius(Double, Double, Double, Double)

使用为矩形的每个角指定的半径值初始化 CornerRadius 类的新实例。Initializes a new instance of the CornerRadius class with the specified radius values for each corner of the rectangle.

属性

BottomLeft

获取或设置左下角的半径。Gets or sets the radius of the bottom-left corner.

BottomRight

获取或设置右下角的半径。Gets or sets the radius of the bottom-right corner.

TopLeft

获取或设置左上角的半径。Gets or sets the radius of the top-left corner.

TopRight

获取或设置右上角的半径。Gets or sets the radius of the top-right corner.

方法

Equals(CornerRadius)

比较两个 CornerRadius 结构是否相等。Compares two CornerRadius structures for equality.

Equals(Object)

确定指定的 Object 是否为 CornerRadius 以及它是否包含与此 CornerRadius 相同的角半径值。Determines whether the specified Object is a CornerRadius and whether it contains the same corner radius values as this CornerRadius.

GetHashCode()

返回此 CornerRadius 的哈希代码。Returns the hash code for this CornerRadius.

ToString()

返回 CornerRadius 的字符串表示形式。Returns the string representation of the CornerRadius.

运算符

Equality(CornerRadius, CornerRadius)

比较两个 CornerRadius 结构是否相等。Compares two CornerRadius structures for equality.

Inequality(CornerRadius, CornerRadius)

比较两个 CornerRadius 结构是否不相等。Compares two CornerRadius structures for inequality.

适用于

另请参阅