How to associate rich text data with MVVM template?

How to dynamically bind data with the document property of a rich text field. Am I using MVVM in Wpf with C #?

EDIT:

I tried with this example in "codeproject.com/KB/WPF/BindableWPFRichTextBox.aspx"; but I can not understand what is happening in this example. I am very new to WPF and MVVM.

He throws an error in the line

try { 
  var stream = new MemoryStream(Encoding.UTF8.GetBytes(GetDocumentXaml(richTextBox)));
  var doc = (FlowDocument)XamlReader.Load(stream); 
  // Set the document 
  richTextBox.Document = doc; 
} 
catch (Exception) { richTextBox.Document = new FlowDocument(); }

the error is similar: "Data at the root level is invalid. Line 1, position 1." I give the meaning as "Sample text"

I found that xaml text should look like

<FlowDocument PagePadding="5,0,5,0" AllowDrop="True" xmlns="schemas.microsoft.com/winfx/2006/xaml/… generated by app back-end</Paragraph>
</FlowDocument>" But how to get this text?
+5
source share
1 answer

, : , ( ) RichTextBox, codeproject. , , , FlowDocument . , "data invalid", FlowDocument

, FlowDocument XAML CodeBehind. http://msdn.microsoft.com/en-us/library/aa970909.aspx

: FlowDocument.

, :

<FlowDocument PagePadding=\"5,0,5,0\" AllowDrop=\"True\" " 
                + "xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">"
                + "<Paragraph>Your sample text</Paragraph></FlowDocument>"
+1

All Articles