Search code examples
silverlighttelerikrad-controls

Get text value in a RadRichTextBox


I have a RadRichTextBox in my Silverlight project which is setup to use basic formatting. Quite frankly I am just using it instead of Textbox in order to take advantage of the Spellchecker feature.

<telerik:RadRichTextBox AllowScaling="False" DocumentInheritsDefaultStyleSettings="True" Height="82" HorizontalAlignment="Left" HorizontalScrollBarVisibility="Hidden" IsContextMenuEnabled="True" IsSelectionMiniToolBarEnabled="False" IsSpellCheckingEnabled="True" Margin="32,61,0,0" Name="radRichTextBox1" VerticalAlignment="Top" VerticalScrollBarVisibility="Hidden" Width="202" />

How would I access the contents of radRichTextBox1 as just text with newlines?


Solution

  • The solution is to simply create a provider and extract the contents as follows:

    var provider = new TxtFormatProvider();
    var result = provider.Export(radRichTextBox1.Document);