Export (0) Print
Expand All

Control.Padding Property

Gets or sets the padding inside a control.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[BindableAttribute(true)] 
public Thickness Padding { get; set; }
/** @property */
public Thickness get_Padding ()

/** @property */
public void set_Padding (Thickness value)

public function get Padding () : Thickness

public function set Padding (value : Thickness)

<object>
  <object.Padding>
    <Thickness .../>
  </object.Padding>
</object>
<object Padding="Thickness" .../>

Property Value

A Thickness. The default value is zero (0).

Padding is the amount of space to insert between the object and its Margin or Border. Padding is specified in the order Left, Top, Right, and Bottom. For more information, see Thickness.

The following example shows how to set the padding property of a control.

<Button Name="btn11" Padding = "5" 
        Click="ChangePadding" TabIndex="1">
  Padding
</Button>

void ChangePadding(object sender, RoutedEventArgs e)
{
    if (btn11.Padding.Left == 5.0)
    {
        btn11.Padding = new Thickness(2.0);
        btn11.Content = "Control Padding changes from 5 to 2.";

    }
    else
    {
        btn11.Padding = new Thickness(5.0);
        btn11.Content = "Padding";
    }
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft