This is a migrated thread and some comments may be shown as answers.

intercepting and altering pasted content

1 Answer 87 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Veteran
Michael asked on 28 Feb 2018, 07:42 AM

Hi all,

I've got a requirement to modify the styling of rich text that's pasted into my radrichtextbox. The following code works, but it hangs the UI when it's run on the main thread, and ClipboardEx.GetDocumentFromClipboard is unhappy when it's not run on the main thread ( something like this https://stackoverflow.com/questions/15913275/backgroundworker-and-clipboard )

Has anybody found a way around this?

 

        private void EditorTextBoxCommandExecuting(object sender, CommandExecutingEventArgs e)
        {
            if (e.Command is PasteCommand)
            {
                DocumentFragment fragment = ClipboardEx
                        .GetDocumentFromClipboard(
                            "RadDocumentGUID"); //copy pasting from a RadRichTextBox, keep the paragraphs as they are
                RemoveStylingFromFragment(fragment);
                Editor.InsertFragment(fragment);

       }

}

                


1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 02 Mar 2018, 02:34 PM
Hello Michael,

Could you please elaborate more on the scenario that you have on your end? Indeed, the code should be run on the main thread, but it shouldn't hang it and I am currently not sure what might cause a similar behavior. Is it always reproducible with different a data or it is related to specific content?

Regards,
Tanya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RichTextBox
Asked by
Michael
Top achievements
Rank 1
Veteran
Answers by
Tanya
Telerik team
Share this question
or