Thickness Thickness Thickness Thickness Struct

定义

描述矩形边框的粗细。Describes the thickness of a frame around a rectangle. 四个 Double 值分别描述矩形的 LeftTopRightBottom 边。Four Double values describe the Left, Top, Right, and Bottom sides of the rectangle, respectively.

public value class Thickness : IEquatable<System::Windows::Thickness>
[System.ComponentModel.TypeConverter(typeof(System.Windows.ThicknessConverter))]
[System.Windows.Localizability(System.Windows.LocalizationCategory.None, Readability=System.Windows.Readability.Unreadable)]
public struct Thickness : IEquatable<System.Windows.Thickness>
type Thickness = struct
Public Structure Thickness
Implements IEquatable(Of Thickness)
继承
属性
实现

示例

下面的示例演示如何使用Thickness 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML)和代码创建结构的实例并设置其属性。The following example shows how to create an instance of a Thickness structure and set its properties by using 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) and code.

myBorder2 = new Border();
myBorder2.BorderBrush = Brushes.SteelBlue;
myBorder2.Width = 400;
myBorder2.Height = 400;
myThickness = new Thickness();
myThickness.Bottom = 5;
myThickness.Left = 10;
myThickness.Right = 15;
myThickness.Top = 20;
myBorder2.BorderThickness = myThickness;
Dim myBorder2 As New Border()
myBorder2.BorderBrush = Brushes.SteelBlue
myBorder2.Width = 400
myBorder2.Height = 400
Dim myThickness As New Thickness()
myThickness.Bottom = 5
myThickness.Left = 10
myThickness.Right = 15
myThickness.Top = 20
myBorder2.BorderThickness = myThickness
<Border BorderBrush="SteelBlue" Width="400" Height="400" Canvas.Left="100" Canvas.Top="100">
  <Border.BorderThickness>
    10,20,15,5
  </Border.BorderThickness>
</Border>

注解

可以通过三Thickness种方式指定值。You can specify Thickness values in three ways. 如果将四个Double值传递给结构, 则它们分别Left表示边框RightBottomTop和边。If you pass four Double values to the structure, they represent the Left, Top, Right and Bottom sides, respectively, of the bounding rectangle. 您还可以提供两Double个值, 第一个值表示边框的左边缘和右边缘, 第二个值表示边框的顶部和底部。You can also supply two Double values, the first value represents the Left and Right sides of the bounding rectangle and the second value represents the Top and Bottom sides of the bounding rectangle. 您还可以提供单个Double值, 将统一值应用于边框的四个边。You can also supply a single Double value, which applies a uniform value to all four sides of the bounding rectangle.

XAML 属性用法XAML Attribute Usage

<object property="left"/>  

-or-

<object property="left,top"/>  

-or-

<object property=" left,top,right,bottom" ... />  

XAML 值XAML Values

leftleft
框架的左边缘, 描述为Double 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)指定度量值的值, 或为qualifiedDouble (请参阅下文)。The left edge of the frame, described as either a Double value that specifies a 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit) measure, or as a qualifiedDouble (see below). 如果只指定了一个度量值, 则该度量值将应用于的Thickness所有左、上、右、下值。If only a single measure is specified, that measure is applied to ALL of the left,top,right,bottom values of a Thickness. 如果只指定了一对左、上个度量值, 则这些度量值将对称Thickness应用于: 向右使用左值; 顶部值用于底部。If only a pair of left,top measures are specified, these measures are applied symmetrically to a Thickness: the left value is used for right; the top value is used for bottom.

toptop
框架的上边缘, 描述为Double 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)指定度量值的值, 或为qualifiedDouble (请参阅下文)。The top edge of the frame, described as either a Double value that specifies a 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit) measure, or as a qualifiedDouble (see below). 如果只指定了一对左、上个度量值, 则这些度量值将对称Thickness应用于: 向右使用左值; 顶部值用于底部。If only a pair of left,top measures are specified, these measures are applied symmetrically to a Thickness: the left value is used for right; the top value is used for bottom.

rightright
框架的右边缘, 描述为Double 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)指定度量值的值, 或为qualifiedDouble (请参阅下文)。The right edge of the frame, described as either a Double value that specifies a 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit) measure, or as a qualifiedDouble (see below). 如果未指定, 将使用左边的值。If left unspecified, will use the left value.

bottombottom
框架的下边缘, 描述为Double 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)指定度量值的值, 或为qualifiedDouble (请参阅下文)。The bottom edge of the frame, described as either a Double value that specifies a 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit) measure, or as a qualifiedDouble (see below). 如果未指定, 将使用左边的值。If left unspecified, will use the left value.

qualifiedDoublequalifiedDouble
上述任何度量值的双精度值, 后跟以下单元声明字符串之一px:、 incmptA double value as described above for any of the measures, followed by one of the following unit declaration strings: px, in, cm, pt.

px(默认值) 是与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)px (default) is 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)

in为英寸;1in = = 96pxin is inches; 1in==96px

cm为厘米;1cm = = (96/2.54) pxcm is centimeters; 1cm==(96/2.54) px

pt为点;1pt = = (96/72) pxpt is points; 1pt==(96/72) px

备注

指定为字符串时, 值不需要显式包含小数点。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.

构造函数

Thickness(Double) Thickness(Double) Thickness(Double) Thickness(Double)

初始化 Thickness 结构的新实例,此结构的各边使用指定的统一长度。Initializes a new instance of the Thickness structure that has the specified uniform length on each side.

Thickness(Double, Double, Double, Double) Thickness(Double, Double, Double, Double) Thickness(Double, Double, Double, Double) Thickness(Double, Double, Double, Double)

初始化 Thickness 结构的新实例,该结构具有矩形各边所应用的特定长度(作为 Double 提供)。Initializes a new instance of the Thickness structure that has specific lengths (supplied as a Double) applied to each side of the rectangle.

属性

Bottom Bottom Bottom Bottom

获取或设置边框底边的宽度(以像素为单位)。Gets or sets the width, in pixels, of the lower side of the bounding rectangle.

Left Left Left Left

获取或设置边框左侧的宽度(以像素为单位)。Gets or sets the width, in pixels, of the left side of the bounding rectangle.

Right Right Right Right

获取或设置边框右边的宽度(以像素为单位)。Gets or sets the width, in pixels, of the right side of the bounding rectangle.

Top Top Top Top

获取或设置边框顶边的宽度(以像素为单位)。Gets or sets the width, in pixels, of the upper side of the bounding rectangle.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

比较此 Thickness 结构与另一个 Object 是否相等。Compares this Thickness structure to another Object for equality.

Equals(Thickness) Equals(Thickness) Equals(Thickness) Equals(Thickness)

比较此 Thickness 与另一个 Thickness 结构是否相等。Compares this Thickness structure to another Thickness structure for equality.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回结构的哈希代码。Returns the hash code of the structure.

ToString() ToString() ToString() ToString()

返回 Thickness 结构的字符串表示形式。Returns the string representation of the Thickness structure.

操作员

Equality(Thickness, Thickness) Equality(Thickness, Thickness) Equality(Thickness, Thickness) Equality(Thickness, Thickness)

比较两个 Thickness 结构的值是否相等。Compares the value of two Thickness structures for equality.

Inequality(Thickness, Thickness) Inequality(Thickness, Thickness) Inequality(Thickness, Thickness) Inequality(Thickness, Thickness)

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

适用于

另请参阅