WPF RichTextBox: How to change selected text font?

前端 未结 5 1675
暗喜
暗喜 2020-12-18 09:46

how can I change the font for a currently selected text area inside a WPF RichTextBox?

5条回答
  •  太阳男子
    2020-12-18 09:55

    To get the current selection use:

    Dim rng As TextRange = New TextRange(YourRtfBox.Selection.Start, YourRtfBox.Selection.End)

    And then set the fontstyle:

    rng.ApplyPropertyValue(Inline.FontSizeProperty, YourFontSizeValue) rng.ApplyPropertyValue(Inline.FontFamilyProperty, YourFontFamilyValue)

提交回复
热议问题