This documentation is archived and is not being maintained.

FlowDocument.IsOptimalParagraphEnabled Property

Gets or sets a value that indicates whether optimal paragraph layout is enabled or disabled. This is a dependency property.

Namespace:  System.Windows.Documents
Assembly:  PresentationFramework (in PresentationFramework.dll)

public bool IsOptimalParagraphEnabled { get; set; }
<object IsOptimalParagraphEnabled="bool" .../>

Property Value

Type: System.Boolean
true if optimal paragraph layout is enabled; otherwise, false. The default is false.

Optimal paragraph layout is a feature that lays out paragraphs in the FlowDocument such that white space is distributed as evenly as possible. Theoretically, this provides an optimized reading experience by eliminating distracting white space that can occur with line-justified text and other layout routines. Optimal paragraph layout is particularly effective when coupled with automatic hyphenation (represented by the IsHyphenationEnabled property).

For a sample that explores the IsOptimalParagraphEnabled property in real time, see Optimal Paragraph and Hyphenation in a FlowDocument Sample.

The following example shows how to set the IsOptimalParagraphEnabled attribute of a FlowDocument element.

    PageWidth="400" PageHeight="480"
      <Hyperlink NavigateUri="">
        Perfect Dark Zero
      Joanna Dark returns in the Xbox 360 exclusive <Bold><Italic>Perfect Dark Zero</Italic></Bold>, the 
      prequel to the internationally award-winning and multi-million selling first-person shooter 
      <Italic>Perfect Dark</Italic> from famed game developer Rare.
      A secret war has begun between shadowy corporations bent on world domination. Joanna Dark and her father 
      Jack are caught up in the fight for the future of the planet. A routine bounty hunting mission rips open 
      a global conspiracy that will change Joanna's destiny—forever.
      Guide Joanna Dark on her journey to become the perfect agent. Featuring a compelling and captivating story, 
      <Italic>Perfect Dark Zero</Italic> plunges you into a world of corporate espionage and conspiracy. The title 
      merges the excitement and intrigue of its predecessor with revolutionary game design, cutting-edge online play,
      and amazing graphics to deliver an experience that defines next-generation gaming and entertainment...

The following figure shows how the preceding FlowDocument renders.

Screenshot: FlowDocument hyphen enabled

The following figure shows how the same FlowDocument renders with the default setting of IsOptimalParagraphEnabled=false.

Screenshot: FlowDocument with disabled hyphens

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

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

// Enable automatic hyphenation.
flowDoc.IsHyphenationEnabled = true;
// Enable optimal paragraph layout.
flowDoc.IsOptimalParagraphEnabled = true;

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