Block.Padding Block.Padding Block.Padding Block.Padding Property

Definición

Obtiene o establece el grosor del relleno para el elemento.Gets or sets the padding thickness for the element.

public:
 property System::Windows::Thickness Padding { System::Windows::Thickness get(); void set(System::Windows::Thickness value); };
public System.Windows.Thickness Padding { get; set; }
member this.Padding : System.Windows.Thickness with get, set
Public Property Padding As Thickness

Valor de propiedad

Estructura Thickness que especifica la cantidad de relleno que se aplicará, en píxeles independientes de dispositivo.A Thickness structure that specifies the amount of padding to apply, in device independent pixels. El valor predeterminado es un grosor uniforme de cero (0,0).The default is a uniform thickness of zero (0.0).

Ejemplos

En el ejemplo siguiente se muestra cómo establecer Padding el atributo de Block un elementoParagraph().The following example shows how to set the Padding attribute of a Block element (Paragraph).

<FlowDocument Background="LightSlateGray" ColumnWidth="2000">
  <Section Background="DarkMagenta" Margin="0" Padding="0">
    <Paragraph Background="White">
      <Run>Default paragraph.</Run>
    </Paragraph>
    <Paragraph Background="White">
      <Run>Default paragraph.</Run>
    </Paragraph>
    <Paragraph Background="LightBlue" Margin="50">
      <Run>This paragraph has a magin of 50 pixels set, but no padding.</Run>
    </Paragraph>
    <Paragraph Background="LightCoral" Padding="50">
      <Run>This paragraph has padding of 50 pixels set, but no margin.</Run>
    </Paragraph>
    <Paragraph Background="LightGreen" Margin="50" Padding="50">
      <Run>This paragraph has both padding and margin set to 50 pixels.</Run>
    </Paragraph>
    <Paragraph Background="White">
      <Run>Default paragraph.</Run>
    </Paragraph>
    <Paragraph Background="White">
      <Run>Default paragraph.</Run>
    </Paragraph>
  </Section>
</FlowDocument>

En la ilustración siguiente se muestra cómo se representa el ejemplo anterior.The following figure shows how the preceding example renders. Los grosores y colores exagerados se usan para la ilustración.Exaggerated thicknesses and colors are used for illustration.

![Captura Captura de pantalla de párrafos con relleno y márgenes]:(~/add/media/block-marginpadding.png " Párrafos con relleno y márgenes")Screenshot: Paragraphs with padding and margins

En el ejemplo siguiente se muestra cómo establecer Padding la propiedad mediante programación.The following example shows how to set the Padding property programmatically.

FlowDocument flowDoc = new FlowDocument();
Section sec = new Section();

flowDoc.Background = Brushes.LightSlateGray;
flowDoc.ColumnWidth = 2000;
sec.Background = Brushes.DarkMagenta;
sec.Padding = sec.Margin = new Thickness(0);

Paragraph defPar1 = new Paragraph(new Run("Default paragraph."));
Paragraph defPar2 = new Paragraph(new Run("Default paragraph."));
Paragraph defPar3 = new Paragraph(new Run("Default paragraph."));
Paragraph defPar4 = new Paragraph(new Run("Default paragraph."));
defPar1.Background = defPar2.Background = defPar3.Background = defPar4.Background = Brushes.White;

Paragraph marginPar = new Paragraph(new Run("This paragraph has a magin of 50 pixels set, but no padding."));
marginPar.Background = Brushes.LightBlue;
marginPar.Margin = new Thickness(50);
Paragraph paddingPar = new Paragraph(new Run("This paragraph has padding of 50 pixels set, but no margin."));
paddingPar.Background = Brushes.LightCoral;
paddingPar.Padding = new Thickness(50);
Paragraph marginPaddingPar = new Paragraph(new Run("This paragraph has both padding and margin set to 50 pixels."));
marginPaddingPar.Background = Brushes.LightGreen;
marginPaddingPar.Padding = marginPaddingPar.Margin = new Thickness(50);

sec.Blocks.Add(defPar1);
sec.Blocks.Add(defPar2);
sec.Blocks.Add(marginPar);
sec.Blocks.Add(paddingPar);
sec.Blocks.Add(marginPaddingPar);
sec.Blocks.Add(defPar3);
sec.Blocks.Add(defPar4);
flowDoc.Blocks.Add(sec);
Dim flowDoc As New FlowDocument()
Dim sec As New Section()

flowDoc.Background = Brushes.LightSlateGray
flowDoc.ColumnWidth = 2000
sec.Background = Brushes.DarkMagenta
sec.Margin = New Thickness(0)
sec.Padding = sec.Margin

Dim defPar1 As New Paragraph(New Run("Default paragraph."))
Dim defPar2 As New Paragraph(New Run("Default paragraph."))
Dim defPar3 As New Paragraph(New Run("Default paragraph."))
Dim defPar4 As New Paragraph(New Run("Default paragraph."))
defPar4.Background = Brushes.White
defPar3.Background = defPar4.Background
defPar2.Background = defPar3.Background
defPar1.Background = defPar2.Background

Dim marginPar As New Paragraph(New Run("This paragraph has a magin of 50 pixels set, but no padding."))
marginPar.Background = Brushes.LightBlue
marginPar.Margin = New Thickness(50)
Dim paddingPar As New Paragraph(New Run("This paragraph has padding of 50 pixels set, but no margin."))
paddingPar.Background = Brushes.LightCoral
paddingPar.Padding = New Thickness(50)
Dim marginPaddingPar As New Paragraph(New Run("This paragraph has both padding and margin set to 50 pixels."))
With marginPaddingPar
    .Background = Brushes.LightGreen
    .Margin = New Thickness(50)
    .Padding = marginPaddingPar.Margin
End With

sec.Blocks.Add(defPar1)
sec.Blocks.Add(defPar2)
sec.Blocks.Add(marginPar)
sec.Blocks.Add(paddingPar)
sec.Blocks.Add(marginPaddingPar)
sec.Blocks.Add(defPar3)
sec.Blocks.Add(defPar4)
flowDoc.Blocks.Add(sec)

Comentarios

Paddinges el espacio en búfer que se encuentra dentro del área de contenido de un elemento, entre el contenido del elemento y el borde interno del elemento.Padding is buffer space that falls inside an element's content area, between the element's content and the inner edge of the element. Compare con Margin, que es el espacio en búfer que está fuera del área de contenido de un elemento, entre los bordes del área de contenido del elemento y los bordes del elemento primario.Contrast with Margin, which is buffer space that falls outside an element's content area, between the edges of the element's content area and the edges of the parent element.

Uso de atributos XAMLXAML Attribute Usage

<object Padding="uniformThickness"/>  
- or -  
<object Padding="independentThickness"/>  
- or -  
<object Padding="qualifiedUniformThickness"/>  
- or -  
<object Padding="qualifiedIndependentThickness"/>  

Valores XAMLXAML Values

uniformThicknessuniformThickness
Representación de cadena de un Double valor único que se aplica uniformemente a las cuatro dimensiones de grosor.String representation of a single Double value to apply uniformly to all four thickness dimensions. Por ejemplo, un valor de "10" es equivalente a un valor de "10,10,10,10".For example, a value of "10" is equivalent to a value of "10,10,10,10". Un valor no calificado se mide en píxeles independientes del dispositivo.An unqualified value is measured in device independent pixels. Las cadenas no deben incluir explícitamente los puntos decimales.Strings need not explicitly include decimal points.

independentThicknessindependentThickness
Representación de cadena de cuatro Double valores ordenados correspondientes a las dimensiones de grosor independiente de izquierda, superior, derecha e inferior, en este orden.String representation of four ordered Double values corresponding to independent thickness dimensions for left, top, right, and bottom, in this order. Los cuatro valores deben separarse con comas; no se permiten espacios.The four values must be separated with commas; spaces are not allowed. Por ejemplo, "5, 10, 15, 20" da como resultado 5 píxeles de relleno a la izquierda del contenido, 10 píxeles de relleno por encima del contenido, 15 píxeles de relleno a la derecha del contenido y 20 píxeles de relleno por debajo del contenido.For example, "5,10,15,20" results in 5 pixels of padding to the left of content, 10 pixels of padding above content, 15 pixels of padding to the right of content, and 20 pixels of padding below the content.

qualifiedUniformThicknessqualifiedUniformThickness
Un valor descrito por uniformThickness seguido de uno de los siguientes especificadores de unidad px: in,.A value described by uniformThickness followed by one of the following unit specifiers: px, in.

px(valor predeterminado) esunidades independientes de dispositivo (1/96 de pulgada por unidad)device-independent units (1/96th inch per unit)px (default) is unidades independientes de dispositivo (1/96 de pulgada por unidad)device-independent units (1/96th inch per unit)

ines pulgadas; 1in = =, 96 PXin is inches; 1in==96px

Por ejemplo, "1in" proporciona un relleno uniforme de 1 pulgada en todas las direcciones.For example, "1in" provides uniform padding of 1 inch in all directions.

qualifiedIndependentThicknessqualifiedIndependentThickness
Un valor descrito por independentThickness, con cada valor independiente seguido de uno de los siguientes especificadores de unidad px: in,.A value described by independentThickness, with each independent value followed by one of the following unit specifiers: px, in.

px(valor predeterminado) esunidades independientes de dispositivo (1/96 de pulgada por unidad)device-independent units (1/96th inch per unit)px (default) is unidades independientes de dispositivo (1/96 de pulgada por unidad)device-independent units (1/96th inch per unit)

ines pulgadas; 1in = =, 96 PXin is inches; 1in==96px

Por ejemplo: "1.5in,0.8in,1.5in,0.8in".For example, "1.5in,0.8in,1.5in,0.8in". Los especificadores de unidad se pueden mezclar u omitir en uno o varios valores.Unit specifiers may be mixed or omitted from one or more values.

Información sobre propiedades de dependenciaDependency Property Information

Campo de identificadorIdentifier field PaddingProperty
Propiedades de metadatos establecidas entrueMetadata properties set to true AffectsMeasure

Se aplica a

Consulte también: