I'm trying to program a simple WordPad (not Notepad) in WPF. And at the very beginning, I ran into a problem.
- Write a text
- Place caret in the middle of text
- Change text size
- The cursor jumps to the end of the run
public MainWindow() { InitializeComponent(); fontSizeComBox.ItemsSource = new List() { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }; } private void fontSizeComBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Run r = new Run(); Paragraph p = new Paragraph(); r.FontSize = (double)fontSizeComBox.SelectedValue; richTextBox.CaretPosition.Paragraph.Inlines.Add(r); richTextBox.CaretPosition = r.ElementStart; richTextBox.Focus(); }
Aucun commentaire:
Enregistrer un commentaire