Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FlowDocument.IsHyphenationEnabled Property

Gets or sets a value that indicates whether automatic hyphenation of words is enabled or disabled.

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

public bool IsHyphenationEnabled { get; set; }
/** @property */
public boolean get_IsHyphenationEnabled ()

/** @property */
public void set_IsHyphenationEnabled (boolean value)

public function get IsHyphenationEnabled () : boolean

public function set IsHyphenationEnabled (value : boolean)

<object IsHyphenationEnabled="bool" .../>

Property Value

true to indicate that automatic breaking and hyphenation of words is enabled; false otherwise. The default value is false.

The automatic word hyphenation feature enables a FlowDocument to automatically break and hyphenate words, based on current layout conditions. This enables long words to begin on one line and continue on this next, and tends to achieve a more even distribution of white space in justified text. Words are broken and hyphenated according to standard grammar rules. Automatic hyphenation is particularly effective when coupled with optimal paragraph layout (represented by the IsOptimalParagraphEnabled property).

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

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

<FlowDocumentReader>
  <FlowDocument
    TextAlignment="Justify" 
    IsHyphenationEnabled="True"
    IsOptimalParagraphEnabled="True"
    Background="LightGray"
    PageWidth="400" PageHeight="480"
  >
    <Paragraph>
      <Hyperlink NavigateUri="http://www.xbox.com/en-US/games/p/perfectdarkzero/default.htm">
        Perfect Dark Zero
      </Hyperlink>
    </Paragraph>
    <Paragraph>
      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.
    </Paragraph>
    <Paragraph>
      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.
    </Paragraph>
    <Paragraph>
      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...
    </Paragraph>
  </FlowDocument>
</FlowDocumentReader>

The following figure shows how the FlowDocument declared above renders.

Screenshot: FlowDocument hyphen enabled

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

Screenshot: FlowDocument with disabled hyphens

The following example shows how to set the IsHyphenationEnabled 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 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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft