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 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.