WPF RichTextBox: How to change selected text font?

前端 未结 5 1658
暗喜
暗喜 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:57

    How about something like:

     TextSelection text = richTextBox.Selection; 
     if (!text.IsEmpty) 
     { 
         text.ApplyPropertyValue(RichTextBox.FontSizeProperty, value); 
     }
    

提交回复
热议问题