Gets or sets the outer margin of an element.
Assembly: PresentationFramework (in PresentationFramework.dll)
The margin is the space between this element and other elements that will be adjacent when layout creates the user interface (UI). Shared elements might be peer elements (such as other elements in the collection of a common parent control), or might also be this element's parent.
Thickness structure rather than as a number so that the margin can be set asymmetrically. The Thickness structure itself supports string type conversion so that you can specify an asymmetric in XAML attribute syntax also.is set as a
Margins are additive for sibling elements in a layout; for example, two adjacent elements both with a margin of 30 set on the adjoining edge would have 60 units of space between them.
Elements that have margins set will not typically constrain the size of the specifiedif the allotted rectangle space is not large enough for the margin plus the element content area. The element content area will be constrained instead when layout is calculated. The only case where margins would be constrained also is if the content is already constrained all the way to zero.
- left, top, right, bottom
The attribute usage will also accept abbreviated values that apply in the order provided, symmetrically and logically. For instance, Margin="20" will be interpreted to mean a Thickness with all properties set to 20. Margin="20,50" will be interpreted to mean a Thickness with Left and Right set to 20, and Top and Bottom set to 50.
The default unit for a Thickness measure is device-independent unit (1/96th inch). You can also specify other units by appending the unit type strings cm, in, or pt to any measure.
Number values provided as XAML attributes need not specify decimal points (0 is acceptable, does not have to be provided as 0.0). For more information on Extensible Application Markup Language (XAML) usage, see Thickness.
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0