ListItem.Padding プロパティ

定義

要素のパディングの厚みを取得または設定します。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

プロパティ値

適用する余白の量を指定する Thickness 構造体。デバイス非依存のピクセル単位で指定します。A Thickness structure that specifies the amount of padding to apply, in device independent pixels. 既定では 0 (0.0) の均一の幅です。The default is a uniform thickness of zero (0.0).

要素の属性Paddingを設定する方法を次の例に示しParagraphます ()。 BlockThe 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>

この例の表示結果を次の図に示します。The following figure shows how this example renders. 図には、誇張された太さと色が使用されています。Exaggerated thicknesses and colors are used for illustration.

スクリーンパディングと余白Screenshot: Paragraphs with padding and margins

次の例では、プログラムをPadding使用してプロパティを設定する方法を示します。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)

注釈

Paddingは要素のコンテンツ領域の内側にあり、要素のコンテンツと要素の内側の境界の間にあるバッファー領域です。Padding is buffer space that falls inside an element's content area, between the element's content and the inner edge of the element. Marginコントラスト。これは、要素のコンテンツ領域の外側にあるバッファー領域であり、要素のコンテンツ領域の端と親要素の端との間にあります。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.

XAML 属性の使用方法XAML Attribute Usage

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

XAML 値XAML Values

uniformThicknessuniformThickness
4つのすべてのDouble太さ寸法に一様に適用される単一値の文字列表現。String representation of a single Double value to apply uniformly to all four thickness dimensions. たとえば、の"10"値は、の"10,10,10,10"値に相当します。For example, a value of "10" is equivalent to a value of "10,10,10,10". 非修飾値は、デバイス非依存のピクセル単位で測定されます。An unqualified value is measured in device independent pixels. 文字列には、小数点を明示的に含める必要があります。Strings need not explicitly include decimal points.

independentThicknessindependentThickness
この順序で、左Double 、上、右、下の独立した太さの寸法に対応する4つの順序付けられた値の文字列表現。String representation of four ordered Double values corresponding to independent thickness dimensions for left, top, right, and bottom, in this order. 4つの値はコンマで区切る必要があります。スペースは使用できません。The four values must be separated with commas; spaces are not allowed. たとえば、"5, 10, 15, 20" の場合、コンテンツの左側に5ピクセルの余白、コンテンツの上に10ピクセルの余白、コンテンツの右側に15ピクセルの余白、コンテンツの下に20ピクセルの余白があります。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
UniformThicknessによって記述される値。 pxその後に、、 inのいずれかの単位指定子が続きます。A value described by uniformThickness followed by one of the following unit specifiers: px, in.

px(既定) はです。デバイスに依存しない単位 (1 単位は 1/96 インチ)device-independent units (1/96th inch per unit)px (default) is デバイスに依存しない単位 (1 単位は 1/96 インチ)device-independent units (1/96th inch per unit)

in はインチ。1in==96pxin is inches; 1in==96px

たとえば、で"1in"は、すべての方向に1インチの均一な余白が用意されています。For example, "1in" provides uniform padding of 1 inch in all directions.

qualifiedIndependentThicknessqualifiedIndependentThickness
IndependentThicknessによって記述される値。 pxそれぞれの値に続けて、 in次のいずれかの単位指定子が続きます。A value described by independentThickness, with each independent value followed by one of the following unit specifiers: px, in.

px(既定) はです。デバイスに依存しない単位 (1 単位は 1/96 インチ)device-independent units (1/96th inch per unit)px (default) is デバイスに依存しない単位 (1 単位は 1/96 インチ)device-independent units (1/96th inch per unit)

in はインチ。1in==96pxin is inches; 1in==96px

たとえば、"1.5in,0.8in,1.5in,0.8in" のようにします。For example, "1.5in,0.8in,1.5in,0.8in". 単位指定子は、1つまたは複数の値から混在させることも、省略することもできます。Unit specifiers may be mixed or omitted from one or more values.

依存プロパティ情報Dependency Property Information

識別子フィールドIdentifier field PaddingProperty
メタデータプロパティがに設定されるtrueMetadata properties set to true AffectsMeasure

適用対象

こちらもご覧ください