Hello,
I am using RadRichTextBox with 3 basic style definitions only. I dont want allow users to use more, this is requirement. I achieved the expected behavior except one situation, pasting content that contains styles from MS Word. I would like to not load Style Definitions from pasted content to RadRichTextBox. My idea was to reload my 3 basic style definitions after paste command executed, because then StyleRepository contains more of them:
private
void
Editor_CommandExecuted(
object
sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutedEventArgs e)
{
if
(e.Command
is
PasteCommand)
{
var styl1 =
this
.Editor.Document.StyleRepository.ElementAtOrDefault(0);
var styl2 =
this
.Editor.Document.StyleRepository.ElementAtOrDefault(1);
var styl3 =
this
.Editor.Document.StyleRepository.ElementAtOrDefault(2);
this
.Editor.Document.StyleRepository.Clear();
this
.Editor.Document.StyleRepository.Add(styl1);
this
.Editor.Document.StyleRepository.Add(styl2);
this
.Editor.Document.StyleRepository.Add(styl3);
}
}
and this works almost ok. When saving this and opening again text is not styled.
But right after paste, after removing this additional styles from pasted content, the pasted content still looks like it has this Style Definitions applied.
Document doesn't have style definitions in collection and RadRichTextBox still shows styled content.
Is it problem with refreshing RadRichTextBox after manual operations on StyleRepository?