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 Extensible Application Markup Language (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 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>

備註

您可以用Thickness三種方式來指定值。You can specify Thickness values in three ways. 如果您將四Double個值傳遞至結構, 它們分別Left代表周RightBottom的、 Top和邊。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
框架的左邊緣, 描述為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). 如果只指定單一量值, 該量值就會套用至的所有左、上、右、下值ThicknessIf only a single measure is specified, that measure is applied to ALL of the left,top,right,bottom values of a Thickness. 如果只指定一組左邊的量值, 則會以對稱的方法將這些量Thickness值套用至: left 值用於 right, 而 top 值則用於底端。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值套用至: left 值用於 right, 而 top 值則用於底端。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.

適用於

另請參閱