This is a migrated thread and some comments may be shown as answers.

DocumentContentChangedInterval and saving when DataContext changes...

1 Answer 59 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Francois Lamy
Top achievements
Rank 1
Francois Lamy asked on 05 Jul 2011, 02:41 PM
I am using the DocumentContentChangedInterval event to prevent the document from saving on every keystroke.  But I am using Data Binding to take the document content and transfer it to a property on my view model.  When the view model changes (i.e. the DataContext is changed), I do not get a commit to the original view model if the DocumentContentChangedInterval has not yet elapsed.  Is there some way to FORCE it to save the content?

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 07 Jul 2011, 10:45 AM
Hello Thomas Whittaker,

Instead of increasing the DocumentContentChangedInterval, you can use an UpdateSourceTrigger and set it to LostFocus or Explicit. In your case more appropriate will probably be the latter, allowing you to manipulate the update of the property of your view model. That is, if you have the following XAML:
<telerik:RadRichTextBox Name="richTextBox" />
<telerikHtml:HtmlDataProvider Name="html"
Html="{Binding MyProperty, UpdateSourceTrigger=Explicit, Mode=TwoWay}" RichTextBox="{Binding ElementName=richTextBox}" />
You can update the source whenever needed by invoking the following method:
private void UpdateRichTextBoxBindingSource()
{
    BindingExpression binding = html.GetBindingExpression(HtmlDataProvider.HtmlProperty);
    binding.UpdateSource();
}
I hope this helps.

Greetings,
Iva
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
RichTextBox
Asked by
Francois Lamy
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or