From c9a7d7fb1d5da3ef23de5d1371ca16d70a4892b1 Mon Sep 17 00:00:00 2001 From: brianlagunas_cp Date: Fri, 17 Jun 2011 20:00:00 +0000 Subject: [PATCH] RichTextBox: using dispatcher to set the text to improve perofrmance. --- .../WPFToolkit.Extended/RichTextBox/RichTextBox.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs index bb4f57a7..0ff3d3cb 100644 --- a/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs +++ b/ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs @@ -1,6 +1,7 @@ using System; using System.Windows; using System.Windows.Data; +using System.Windows.Threading; namespace Microsoft.Windows.Controls { @@ -44,7 +45,15 @@ namespace Microsoft.Windows.Controls // if the text is not being set internally then load the text into the RichTextBox if (!rtb._textSetInternally) - rtb.TextFormatter.SetText(rtb.Document, (string)e.NewValue); + { + if (!rtb._textSetInternally) + { + Dispatcher.CurrentDispatcher.BeginInvoke(new Action(delegate() + { + rtb.TextFormatter.SetText(rtb.Document, (string)e.NewValue); + }), DispatcherPriority.Background); + } + } } private static object CoerceTextProperty(DependencyObject d, object value)