Thickness Struct

Definition

Describes the thickness of a frame around a rectangle.Describes the thickness of a frame around a rectangle. Four Double values describe the Left, Top, Right, and Bottom sides of the rectangle, respectively.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)
Inheritance
Thickness
Attributes
Implements

Examples

下列範例示範如何使用 Extensible Application Markup Language (XAML)Extensible Application Markup Language (XAML) 和程式碼來建立 Thickness 結構的實例,並設定其屬性。The following example shows how to create an instance of a Thickness structure and set its properties by using Extensible Application Markup Language (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>

Remarks

您可以用三種方式指定 Thickness 值。You can specify Thickness values in three ways. 如果您將四個 Double 值傳遞至結構,它們分別代表周框矩形的 LeftTopRightBottom 邊。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 Attribute UsageXAML Attribute Usage

<object property="left"/>  

-或--or-

<object property="left,top"/>  

-或--or-

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

XAML 值XAML Values

leftleft
框架的左邊緣,描述為指定 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 量值的 Double 值,或做為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:左邊的值用於 right;最上方的值會用於底端。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
框架的上邊緣,描述為指定 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 量值的 Double 值,或做為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:左邊的值用於 right;最上方的值會用於底端。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
框架的右邊緣,描述為指定 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 量值的 Double 值,或做為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.

bottom
框架的下邊緣,描述為指定 裝置獨立單位 (每單位 1/96 英吋)device-independent units (1/96th inch per unit) 量值的 Double 值,或做為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
上述任何量值的雙精度浮點數,後面接著下列其中一個單元宣告字串: pxincmptA 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

Note

當指定為字串時,值不需要明確包含小數點。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.

Constructors

Thickness(Double)

Initializes a new instance of the Thickness structure that has the specified uniform length on each side.Initializes a new instance of the Thickness structure that has the specified uniform length on each side.

Thickness(Double, Double, Double, Double)

Initializes a new instance of the Thickness structure that has specific lengths (supplied as a Double) applied to each side of the rectangle.Initializes a new instance of the Thickness structure that has specific lengths (supplied as a Double) applied to each side of the rectangle.

Properties

Bottom

Gets or sets the width, in pixels, of the lower side of the bounding rectangle.Gets or sets the width, in pixels, of the lower side of the bounding rectangle.

Left

Gets or sets the width, in pixels, of the left side of the bounding rectangle.Gets or sets the width, in pixels, of the left side of the bounding rectangle.

Right

Gets or sets the width, in pixels, of the right side of the bounding rectangle.Gets or sets the width, in pixels, of the right side of the bounding rectangle.

Top

Gets or sets the width, in pixels, of the upper side of the bounding rectangle.Gets or sets the width, in pixels, of the upper side of the bounding rectangle.

Methods

Equals(Object)

Compares this Thickness structure to another Object for equality.Compares this Thickness structure to another Object for equality.

Equals(Thickness)

Compares this Thickness structure to another Thickness structure for equality.Compares this Thickness structure to another Thickness structure for equality.

GetHashCode()

Returns the hash code of the structure.Returns the hash code of the structure.

ToString()

Returns the string representation of the Thickness structure.Returns the string representation of the Thickness structure.

Operators

Equality(Thickness, Thickness)

Compares the value of two Thickness structures for equality.Compares the value of two Thickness structures for equality.

Inequality(Thickness, Thickness)

Compares two Thickness structures for inequality.Compares two Thickness structures for inequality.

Applies to

See also