WPF RichTextBox: How to change selected text font?

前端 未结 5 1673
暗喜
暗喜 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 10:00

    To change the font family for a selection in the RichTextBox you should use this:

    text.ApplyPropertyValue(Run.FontFamilyProperty, value);
    

    The selected text in a RichTextBox is a Run object, so one must use the Run Dependency Properties. This seems to work in Silverlight at least, so should be the same thing in WPF.

提交回复
热议问题