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);
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?
Tanya source
share