I have a WPF RichTextBox and i'm trying to do is change the style: FontFamily, FontSize, FontWeight, Color and some more.
I can change some of this values on the selected Text, but i can't find a TextDecorationProperty
CodeExample:
TextSelection textRange = richTextBoxWpf.Selection;
if (btBold.IsChecked ?? false)
{
textRange.ApplyPropertyValue(FontWeightProperty, FontWeights.Bold);
btBold.IsChecked = true;
}
else
{
btBold.IsChecked = false;
textRange.ApplyPropertyValue(FontWeightProperty, FontWeights.Normal);
}
My code fails on set the Property:
var pens = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1);
textRange.ApplyPropertyValue(TextDecoration.PenProperty, pens);
Fail Error-Message: "Die Pen-Eigenschaft ist für die Textformatierung nicht gültig."