WPF RichTextBox Selection property bug?
The next code works perfectly (it changes the font size for 开发者_StackOverflow中文版-only- the selected text):
MyRichTextBox.Selection.ApplyPropertyValue(RichTextBox.FontSizeProperty, 18);
But the next code changes the font for the entire document, not only the selected text:
var SelectedFont = new FontFamily("Tahoma");
MyRichTextBox.Selection.ApplyPropertyValue(RichTextBox.FontFamilyProperty, SelectedFont);
Has anybody changed successfully only a selected text? if so... how?
The default FontFamily in Visual Studio, in my case, is also Tahoma for both a Window and a RichTextBox.
Try switching your RichTextBox default FontFamily to Georgia, and temporarily make the font size 20 to see if the differences become visible.
Your code worked for me as is using .NET 3.5 SP1.
精彩评论