


dimensions
Dimensions should be set in increments of 4 effective pixels.
- Height/- Widthspecify element size. Default =- NaN. Use- Autoor star sizing for fluid behavior.
- ActualHeight/- ActualWidthreport element size at runtime and are changed in a- SizeChangedevent.
- MinWidth/- MaxWidthand- MinHeight/- MaxHeightprovide constraints while still supporting fluid sizing.
- Text element dimensions are controlled by FontSize.- They do not have a Height / Width property but do have a calculated ActualHeight/ActualWidth.
 
- They do not have a Height / Width property but do have a calculated 
alignment
- HorizontalAlignment—- Left,- Center,- Right,- Stretch(default)
- VerticalAlignment—- Top,- Center,- Bottom,- Stretch(default)
- HorizontalContentAlignment/- VerticalContentAlignmentspecify how children are positioned in the container.
- Text elements use the TextAlignmentproperty (default=left-alignment)
margin
The amount of empty space around an element. Margin should be set in increments of 4 effective pixels.
- Does not add pixels to ActualHeight/ActualWidth.
- Uniform margin (Margin="20") results in margin of 20 pixels left, top, right, bottom.
- Distinct margin (Margin="0 10 5 25") sets each side individually.
- If two elements both specify a margin of 10 pixels and are adjacent, the distance between them will be 20 pixels.
- Negative margins are supported but discouraged (can cause clipping).
- Margin values are constrained last—can cause an element’s dimension to be constrained to 0.
padding
The amount of empty space between the inner border of an element and its child content/elements. Padding should be set in increments of 4 effective pixels.
- A positive padding value decreases the content area of the element.
- Does not inherit from FrameworkElement(unlike dimensions, alignment, and margin).
Several classes define their own padding property:
- Control.Padding—for all Control derived classes- For controls that have no content, this property does nothing.
- For controls that have a border, the padding applies inside that border.
 
- Border.Padding—space between the rectangle line created by- BorderThickness/- BorderBrushand the- Childelement.
- ItemsPresenter.Padding—for items in item controls.
- TextBlock.Paddingand- RichTextBlock.Padding—expand the bounding box around the text element.- Recommendation: use Marginsettings onBlockcontainers instead since padding can be visually difficult to see because these elements have no background.
 
- Recommendation: use 
Example:
Margin="0", Padding="0"

<Grid BorderBrush="Blue" BorderThickness="4" Width="200">
<TextBox Text="This is text in a TextBox." Margin="20" Padding="16,24"/>
</Grid>
