The purpose these data providers (and XamlDataProvider in particular) is to suit for any scenario requiring XAML-only binding. A vivid example of this is using RIA Services and the MVVM model for creating applications. However, if you'd like to hook RadRichTextBox's contents to a code behind variable, you basically have two options:
1. Mimic what the data provider does internally: hook to the RadRichTextBox.DocumentContentChanged event and in the handler use the XamlFormatProvider in order to update your code-behind object/variable.
2. Create a XamlDataProvider and create a binding from code behind and bind that to your variable. Here's how to do that:
XamlDataProvider dataProvider =
dataProvider.RichTextBox = radRichTextBox;
Binding xamlBinding =
xamlBinding.Source = MyObject;
xamlBinding.Mode = BindingMode.TwoWay;
BindingOperations.SetBinding(dataProvider, XamlDataProvider.XamlProperty, xamlBinding);
However, there is one small caveat here - make sure to declare the XamlDataProvider in the control scope in order to keep a reference to it. Otherwise it may get garbage collected. Additionally, this way you may bind only to properties and not fields or static variables.
It's up to you to pick whichever approach feels more natural to you.
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Public Issue Tracking
system and vote to affect the priority of the items