更改书写字体样式而不更改以前编写的文本

Change the writing fontstyle without changing the previously written text

这是我将字体样式更改为正常的代码。但我的问题是它更改了 RichTextBox 中的所有文本。我要的是它会改变选中的文字,改变我要写的文字的样式。

        private void italicToggle_Unchecked(object sender, RoutedEventArgs e)
        {
        text.Selection.ApplyPropertyValue(FontStyleProperty, FontStyles.Normal);
        text.FontStyle = FontStyles.Italic;
        }

文本框只包含“未格式化的文本”。也就是说,您可以为整个文本框设置字体或字体样式等,但不能为部分(选择)设置。为了能够更改文本的一部分,您必须使用 RichTextBox (RichTextBox Class). And see this for an overview (RichTextBox Overview)。