private void fontFamilyBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.AddedItems.Count > 0 && fontFamilyBox.SelectedItem != null)
     {
         TextEditing.SetRTBValue(FontFamilyProperty, fontFamilyBox.SelectedItem.ToString(), true);
     }
 }
        private void UpdateFontSize(bool focusRTB)
        {
            string text = fontSizeBox.Text;

            double value;

            if (double.TryParse(text, out value))
            {
                TextEditing.SetRTBValue(FontSizeProperty, Converter.PixelToPoint(value), focusRTB, _rtb);

                bool found = false;

                foreach (ComboBoxItem each in fontSizeBox.Items)
                {
                    if (each.Content.ToString() == text)
                    {
                        each.IsSelected = true;
                        found           = true;
                        break;
                    }
                }

                if (!found)
                {
                    fontSizeBox.SelectedIndex = -1;
                    fontSizeBox.Text          = text;
                }
            }
        }
        private void fontSizeBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                string newSize = (string)((ContentControl)fontSizeBox.SelectedItem).Content;

                double value;

                if (double.TryParse(newSize, out value))
                {
                    TextEditing.SetRTBValue(FontSizeProperty, Converter.PixelToPoint(value), true);
                }
            }
        }
        private void UpdateFontFamily(bool focusRTB)
        {
            string text = fontFamilyBox.Text;

            TextEditing.SetRTBValue(FontFamilyProperty, text, focusRTB, _rtb);

            bool found = false;

            for (int i = 0; i < fontFamilyBox.Items.Count; i++)
            {
                if (fontFamilyBox.Items[i].ToString() == text)
                {
                    fontFamilyBox.SelectedIndex = i;
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                fontFamilyBox.SelectedIndex = -1;
                fontFamilyBox.Text          = text;
            }
        }
 private void highlightColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(TextElement.BackgroundProperty, highlightColor.SelectedColor, true, _rtb);
 }
 private void fontColor_OnSelectedChangedEvent(object sender, EventArgs e)
 {
     TextEditing.SetRTBValue(ForegroundProperty, fontColor.SelectedColor, true, _rtb);
 }