Browse Source

RichTextBox: fixed but when using a custom TextFormatter inside a DataTemplate.

pull/1645/head
brianlagunas_cp 16 years ago
parent
commit
62587a34fb
  1. 19
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs

19
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/RichTextBox/RichTextBox.cs

@ -10,7 +10,7 @@ namespace Microsoft.Windows.Controls
#region Private Members #region Private Members
private bool _textHasLoaded; private bool _textHasLoaded;
private bool isInvokePending; private bool _isInvokePending;
#endregion //Private Members #endregion //Private Members
@ -24,9 +24,9 @@ namespace Microsoft.Windows.Controls
public RichTextBox(System.Windows.Documents.FlowDocument document) public RichTextBox(System.Windows.Documents.FlowDocument document)
: base(document) : base(document)
{ {
} }
#endregion //Constructors #endregion //Constructors
#region Properties #region Properties
@ -77,6 +77,11 @@ namespace Microsoft.Windows.Controls
set set
{ {
_textFormatter = value; _textFormatter = value;
//if the Text has already been set and we are changing the TextFormatter then re-set the text
if (_textHasLoaded)
_textFormatter.SetText(Document, Text);
} }
} }
@ -88,10 +93,10 @@ namespace Microsoft.Windows.Controls
private void InvokeUpdateText() private void InvokeUpdateText()
{ {
if (!isInvokePending) if (!_isInvokePending)
{ {
Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(UpdateText)); Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(UpdateText));
isInvokePending = true; _isInvokePending = true;
} }
} }
@ -106,7 +111,7 @@ namespace Microsoft.Windows.Controls
if (_textHasLoaded) if (_textHasLoaded)
Text = TextFormatter.GetText(Document); Text = TextFormatter.GetText(Document);
isInvokePending = false; _isInvokePending = false;
} }
#endregion //Methods #endregion //Methods

Loading…
Cancel
Save