Hello everyone, I have a little bug in my WPF application, that is bugging me. I am changing the font size of my text in my richtextbox, the weird thing is, that sometimes it works, and sometimes it doesn't,
It's very weird, and I was thinking that someone, would have an idea why?
This is the part of the code that controls that
private void NoteContent_SelectionChanged(object sender, RoutedEventArgs e) {
var selectionFontWeight = NoteContent.Selection.GetPropertyValue(TextElement.FontWeightProperty);
boldBton.IsChecked = (selectionFontWeight != DependencyProperty.UnsetValue)
&& selectionFontWeight.Equals(FontWeights.Bold);
var selectionFontStyle = NoteContent.Selection.GetPropertyValue(TextElement.FontStyleProperty);
italicBton.IsChecked = (selectionFontStyle != DependencyProperty.UnsetValue)
&& selectionFontStyle.Equals(FontStyles.Italic);
var selectionFontDecoration = NoteContent.Selection.GetPropertyValue(Inline.TextDecorationsProperty);
UndelineBton.IsChecked = (selectionFontDecoration != DependencyProperty.UnsetValue)
&& selectionFontDecoration.Equals(TextDecorations.Underline);
FontsComboBox.SelectedItem = NoteContent.Selection.GetPropertyValue(FontFamilyProperty);
SizeConboBox.Text = (NoteContent.Selection.GetPropertyValue(FontSizeProperty)).ToString();
}
private void FontsComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
if (FontsComboBox.SelectedItem != null) {
NoteContent.Selection.ApplyPropertyValue(FontFamilyProperty, FontsComboBox.SelectedItem);
}
}
private void SizeConboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
NoteContent.Selection.ApplyPropertyValue(FontSizeProperty, SizeConboBox.Text);
}
Another thing to mention is that if I change my font family to "Arial", it will work fine but the rest no, or sometimes I have to change it twice in order to see the effect

