FlowDocument.IsHyphenationEnabled 属性

定义

获取或设置一个值,该值指示是否启用文字的自动断字功能。

public:
 property bool IsHyphenationEnabled { bool get(); void set(bool value); };
public bool IsHyphenationEnabled { get; set; }
member this.IsHyphenationEnabled : bool with get, set
Public Property IsHyphenationEnabled As Boolean

属性值

Boolean

如果启用自动对文字进行断字和添加连字符,则为 true;否则为 false。 默认值为 false

示例

以下示例演示如何设置 IsHyphenationEnabled 元素的属性 FlowDocument

<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>

下图显示了上述 FlowDocument 呈现方式。

屏幕快照:启用连字符的 FlowDocument

下图显示了与默认设置IsHyphenationEnabled=false相同的FlowDocument呈现方式。

屏幕快照:具有禁用的连字符的 FlowDocument

以下示例演示如何以编程方式设置 IsHyphenationEnabled 属性。

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;
Dim flowDoc As New FlowDocument(New Paragraph(New Run("A bit of text content...")))

' Enable automatic hyphenation.
flowDoc.IsHyphenationEnabled = True
' Enable optimal paragraph layout.
flowDoc.IsOptimalParagraphEnabled = True

注解

自动单词连字符功能允许 FlowDocument 基于当前布局条件自动中断和连字符单词。 这样,长字就可以在一行上开始,然后继续下一行,并且倾向于在对齐文本中实现更均匀的空白分布。 单词根据标准语法规则进行断字符和连字符。 当与属性) 表示 IsOptimalParagraphEnabled 的最佳段落布局 (耦合时,自动连字符特别有效。

依赖项属性信息

标识符字段 IsHyphenationEnabledProperty
元数据属性设置为 true AffectsMeasureAffectsRenderInherits

适用于