From 7f5a1b75f526e083a7d028d5617a79819ee74fff Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Tue, 2 Nov 2010 03:33:13 +0000 Subject: [PATCH] RichtextBoxFormatBar: fixed bug where text would loose highlight after first text transformation was applied. --- .../RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs index 2ca2acae..6b3bbe71 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBoxFormatBar/RichTextBoxFormatBarManager.cs @@ -75,6 +75,14 @@ namespace Microsoft.Windows.Controls HideAdorner(); } + void RichTextBox_TextChanged(object sender, TextChangedEventArgs e) + { + //this fixes the bug when applying text transformations the text would lose it's highlight. That was because the RichTextBox was losing focus + //so we just give it focus again and it seems to do the trick of re-highlighting it. + if (!_richTextBox.IsFocused) + _richTextBox.Focus(); + } + #endregion //Event Handlers #region Methods @@ -89,6 +97,7 @@ namespace Microsoft.Windows.Controls _richTextBox = richTextBox; _richTextBox.PreviewMouseMove += RichTextBox_PreviewMouseMove; _richTextBox.PreviewMouseLeftButtonUp += RichTextBox_PreviewMouseLeftButtonUp; + _richTextBox.TextChanged += RichTextBox_TextChanged; _adorner = new UIElementAdorner(_richTextBox);