Hi,
I am using the XamRichTextEditor in an XamGrid TemplateColumn and i have problems by comparing the richtextdocument. What i want to achieve is that if a user clicks in the cell and updates something in the XamRichTextEditor document i want to save the new version in the database.
I have the following xaml column configuration:
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
ClipboardOperationExecuting="DescriptionEditor_OnClipboardOperationExecuting" GotFocus="DescriptionEditor_OnGotFocus"LostFocus="DescriptionEditor_OnLostFocus" Height="Auto"/> RefreshTrigger="Delayed" DelayAfterLastEdit="00:00:01.00" Visibility="Collapsed" Value="{Binding Document}"/>
I have handled the following two events for this:
1) OnGotFocus -> Here i am saving the current RTF document to a stream by using the SaveToRtf method
2) OnLostFocus -> Her i am saving the new/updated RTF document to a stream by using the SaveToRtf method
The problem is now that if the user doesn't change anything i also get differences betweent the two streams. Why is that? Whats the Problem here?
How can i check if two rtf documents are equal? And how can i check if an document is empty?
Also if i "Export Content" from the Samples Browser i get different output and cannot compare two rtf documents.
Thanks in Advance!
Best Regards
Rene
Hello Rene,
I am really glad, I could help out. If you do not have any further questions, please verify this thread as answered, so it helps other users as well.
Thanks,
Teodor
Software Developer
Infragistics
www.infragistics.com/support
Wow, thanks for the fast and helpful reply!
Now everything works perfect!
BR,
Thank you for your post. This is the correct behavior when saving to rtf format since the xamRichTextEditor is not only saving the content but it saves also metadata like "Create Time", "Edit Time" , "Creator/Modifier" and other stuffs which is different every time you save even you have not change the content.
However I have created for you a custom Serializer which you can use to compare two files. This serializer excludes the metadata and includes things related to the content only like: ParagraphSettings, CharacterSettings, Text, Styles etc.
For comparing empty document you can use the following approach:
if (string.IsNullOrEmpty(RTE.Document.GetTextInSpan(DocumentSpan.All))) { //Empty text in the xamRichTextEditor }
Please review the attached project and see whether it works for you. If you have more questions do not hesitate to ask.
Thanks,TeodorInfragistics Inc.www.infragistics.com