FlowDocument.PagePadding Property

Updated: February 2009

Gets or sets a value that indicates the thickness of padding space between the boundaries of a page and the page's content. This is a dependency property.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public Thickness PagePadding { get; set; }
<object>
  <object.PagePadding>
    <Thickness .../>
  </object.PagePadding>
</object>
<object PagePadding="uniformThickness"/>
- or -
<object PagePadding="independentThickness"/>
- or -
<object PagePadding="qualifiedUniformThickness"/>
- or -
<object PagePadding="qualifiedIndependentThickness"/>

XAML Values

uniformThickness

String representation of a single Double value to apply uniformly to all four thickness dimensions. 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.

independentThickness

String representation of four ordered Double values corresponding to independent thickness dimensions for left, top, right, and bottom, in this order. The four values must be separated with commas; spaces are not allowed. 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.

qualifiedUniformThickness

A value described by uniformThickness followed by one of the following unit specifiers: px, in.

px (default) is device-independent units (1/96th inch per unit)

in is inches; 1in==96px

For example, "1in" provides uniform padding of 1 inch in all directions.

qualifiedIndependentThickness

A value described by independentThickness, with each independent value followed by one of the following unit specifiers: px, in.

px (default) is device-independent units (1/96th inch per unit)

in is inches; 1in==96px

For example, "1.5in,0.8in,1.5in,0.8in". Unit specifiers may be mixed or omitted from one or more values.

Auto

Causes PagePadding to be set to LineHeight. Equivalent to a property value of Double.NaN.

Property Value

Type: System.Windows.Thickness
A Thickness structure that specifies the amount of padding to apply, in device independent pixels. A value of Double.NaN (equivalent to an attribute value of "Auto") causes PagePadding to be set to LineHeight. The default is a uniform thickness of "Auto".

Identifier field

PagePaddingProperty

Metadata properties set to true

AffectsMeasure

PagePadding can be described as uniform in all directions (PagePadding="10"), or as four distinct values that represent left, top, right, and bottom padding independently (PagePadding="5,0,10,20").

If a specified padding thickness exceeds the corresponding page dimension (for example, the sum of the left and right padding widths exceeds the page width), the thickness of the padding will be proportionally reduced to be no greater than the relevant page dimension.

The following examples show various ways to set the PagePadding attribute of a FlowDocument element.

<FlowDocumentReader>
  <FlowDocument PagePadding="10">
    <Paragraph>Padding is 10 pixels all around.</Paragraph>
  </FlowDocument>
</FlowDocumentReader>

<FlowDocumentReader>
  <FlowDocument PagePadding="1.5in">
    <Paragraph>Padding is 1 and a half inches all around.</Paragraph>
  </FlowDocument>
</FlowDocumentReader>

<FlowDocumentReader>
  <FlowDocument PagePadding="5,10,5,10">
    <Paragraph>Padding is 5 pixels on the right and left, and 10 pixels on the top and botton.</Paragraph>
  </FlowDocument>
</FlowDocumentReader>

<FlowDocumentReader>
  <FlowDocument PagePadding="0.8in,20,0.8in,20">
    <Paragraph>Padding is 1 eigth of an inch on the right and left, and 20 pixels on the top and botton.</Paragraph>
  </FlowDocument>
</FlowDocumentReader>

The following example shows how to set the PagePadding property programmatically.

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));

// Padding is 10 pixels all around.
flowDoc.PagePadding = new Thickness(10);
// Padding is 5 pixels on the right and left, and 10 pixels on the top and botton.
flowDoc.PagePadding = new Thickness(5, 10, 5, 10);

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0

Date

History

Reason

February 2009

Corrected the stated default value.

Content bug fix.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft