Thickness structure

Applies to Windows and Windows Phone

Describes the thickness of a frame around a rectangle. Four Double values describe the Left, Top, Right, and Bottom sides of the rectangle, respectively.

Syntax


public struct Thickness


<Thickness ...>uniform</Thickness>
- or -
<Thickness ...>left&right,top&bottom</Thickness>
- or -
<Thickness ...>left,top,right,bottom</Thickness>


<object property="uniform"/>
- or -
<object property="left&right,top&bottom"/>
- or -
<object property="left,top,right,bottom" ... />

XAML Values

uniform

A numeric value that specifies a uniform Thickness. The uniform value is applied to all four Thickness values (Left, Top, Right, and Bottom).

left&right

A numeric value that specifies the Left and Right of a symmetrical Thickness.

top&bottom

A numeric value that specifies the Top and Bottom of a symmetrical Thickness.

left,top,right,bottom

Numeric values that specify the four possible dimension values of a Thickness structure (Left, Top, Right, and Bottom).

Attributes

[Version(0x06020000)]
[WebHostHidden()]

Members

The Thickness structure has these types of members:

Constructors

The Thickness structure has these constructors.

ConstructorDescription
Thickness(Double) Initializes a Thickness structure that has the specified uniform length on each side.
Thickness(Double, Double, Double, Double) Initializes a Thickness structure that has specific lengths (each supplied as a Double) applied to each side of the rectangle.

 

Fields

The Thickness structure has these fields.

FieldData typeDescription
Bottom

System.Double [.NET] | float64 [C++]

The bottom edge measure of the Thickness.

Left

System.Double [.NET] | float64 [C++]

The left side measure of the Thickness.

Right

System.Double [.NET] | float64 [C++]

The right side measure of the Thickness.

Top

System.Double [.NET] | float64 [C++]

The top edge measure of the Thickness.

 

Methods

The Thickness structure has these methods. It also inherits methods from the Object class.

MethodDescription
Equals(Object) [C#, VB]Determines whether the specified object is equal to a Thickness.
GetHashCode [C#, VB]Gets a hash code for this object.
ToString [C#, VB]Converts a Thickness to a String representation.

 

Operators

The Thickness structure has these operators.

OperatorDescription
Equality Compares two Thickness structures for equality.
Inequality Compares two Thickness structures for inequality.

 

Properties

The Thickness structure has these properties.

PropertyAccess typeDescription

Bottom

Read/writeGets or sets the width, in pixels, of the lower side of the bounding rectangle.

Left

Read/writeGets or sets the width, in pixels, of the left side of the bounding rectangle.

Right

Read/writeGets or sets the width, in pixels, of the right side of the bounding rectangle.

Top

Read/writeGets or sets the width, in pixels, of the upper side of the bounding rectangle.

 

Remarks

Thickness values are generally used to set properties that affect the layout of the object where the property is set. Properties that use a Thickness value include:

In XAML, you can specify Thickness values in several ways. If you specify four Double values, these represent the Left, Top, Right, and Bottom sides, respectively, of the bounding rectangle. if you specify two values, these represent the Left, Top values, and also applies the same values to Right and Bottom such that the resulting Thickness is isometric horizontally and isometric vertically. You can also supply a single value, which applies a uniform value to all four sides of the bounding rectangle.

Values assigned from code do not have any behavior that can extrapolate values. If you set the value for a Left property or field, you do not automatically establish the same value for Right. All Thickness properties must be set discretely in code. You can use the Thickness(Double) or Thickness(Double,Double,Double,Double) constructors rather than assigning values to properties.

Although the type of the data values of a Thickness is Double, you typically specify integer values.

Notes on XAML syntax

A string that specifies three values does not cause a parser error, but only the first two values are interpreted, and any third value is ignored.

Although you can specify a Thickness as an object element, you cannot specify the individual values such as Top as attributes of that object element. The XAML parser does not support setting XAML attribute values for this structure. Instead, you must specify the values as initialization text within the Thickness. Using the object element syntax for a Thickness is useful if you want to declare a keyed resource that can be used by multiple Control instances for their Padding. For more info on XAML initialization text, see Basic XAML syntax guide.

You can use a space rather than a comma as the delimiter between values.

Projection and members of Thickness

If you are using a Microsoft .NET language (C# or Microsoft Visual Basic), or in Visual C++ component extensions (C++/CX), then Thickness has non-data members available, and its data members are exposed as read-write properties, not fields.

If you are programming with C++ using the Windows Runtime Template Library (WRL), then only the data member fields exist as members of Thickness, and you cannot use the utility methods or properties listed in the members table. WRL code can access similar utility methods that exist on the ThicknessHelper class.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd
Platform.winmd

Assembly

System.Runtime.WindowsRuntime.UI.Xaml.dll

See also

Border
Control
Quickstart: Defining layouts

 

 

Show:
© 2014 Microsoft. All rights reserved.