Padding
A Padding property describes the distance between an element and any child elements or content that it contains. Content is treated as a single bounding box that encloses all the content, if it's an element that permits more than one child. For example, if there's an ItemsControl that contains two items, the Padding is applied around the bounding box that contains the items. Padding subtracts from the available size when it comes to the measure and arrange pass calculations for that container and are part of the desired size values when the container itself goes through the layout pass for whatever contains it. Unlike Margin, Padding is not a property of FrameworkElement, and in fact there are several classes which each define their own Padding property:
• Control.Padding: inherits to all Control derived classes. Not all controls have content, so for some controls (for example AppBarSeparator) setting the property does nothing. If the control has a border (seeControl.BorderThickness), the padding applies inside that border.
• Border.Padding: defines space between the rectangle line created by BorderThickness/BorderBrush and theChild element.
• ItemsPresenter.Padding: contributes to appearance of the generated visuals for items in item controls, placing the specified padding around each item.
• TextBlock.Padding and RichTextBlock.Padding: expands the bounding box around the text of the text element. These text elements don't have a Background, so it can be visually difficult to see what's the text's padding versus other layout behavior applied by the text element's container. For that reason, text element padding is seldom used and it's more typical to use Margin settings on contained Block containers (for the RichTextBlockcase).
In each of these cases, the same element also has a Margin property. If both margin and padding are applied, they are additive in the sense that the apparent distance between an outer container and any inner content will be margin plus padding. If there are different background values applied to content, element or container, the point at which margin ends and padding begins is potentially visible in the rendering.
Dimensions (Height, Width)
The Height and Width properties of a FrameworkElement often influence how the alignment, margin, and padding properties behave when a layout pass happens. In particular, real-number Height and Width value cancels Stretchalignments, and is also promoted as a possible component of the DesiredSize value that's established during the measure pass of the layout. Height and Width have constraint properties: the Height value can be constrained withMinHeight and MaxHeight, the Width value can be constrained with MinWidth and MaxWidth. Also, ActualWidthand ActualHeight are calculated, read-only properties that only contain valid values after a layout pass has completed. For more info about how the dimensions and constraints or calculated properties interrelate, see Remarks inFrameworkElement.Height and FrameworkElement.Width.