I'd like to filter out hyperlinks when the user pastes into a RadRichTextBox editor control. We are using RichTextBoxUI.dll from UI for WPF version 2014.2.617.40.
The examples found the following threads set e.Cancel = true to cancel the paste operation.
e.Cancel is not visible in Telerik.Windows.Controls.RichTextBoxUI.DLL v2014.2.617.40
How can the paste command be cancelled? For example, cancel any paste command with an image in it.
The second related thread has this sample code to remove hyperlinks.
void radRichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
DocumentFragment fragment = ClipboardEx.GetDocument();
if (fragment != null)
{
TxtFormatProvider provider=new TxtFormatProvider();
string plainText = provider.Export(fragment.ToDocument());
this.radRichTextBox.InsertFragment(new DocumentFragment(provider.Import(plainText)));
e.Cancel = true;
}
}
}
Related threads:
- How to paste plain text http://www.telerik.com/forums/paste-plain-text
- How to remove hyperlinks http://www.telerik.com/forums/remove-hyperlinks-when-executing-pastecommand
- Preventing paste of images http://www.telerik.com/forums/limiting-the-radrichtextbox (Silverlight)
The examples found the following threads set e.Cancel = true to cancel the paste operation.
e.Cancel is not visible in Telerik.Windows.Controls.RichTextBoxUI.DLL v2014.2.617.40
How can the paste command be cancelled? For example, cancel any paste command with an image in it.
The second related thread has this sample code to remove hyperlinks.
void radRichTextBox_CommandExecuting(object sender, Telerik.Windows.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
if (e.Command is PasteCommand)
{
DocumentFragment fragment = ClipboardEx.GetDocument();
if (fragment != null)
{
TxtFormatProvider provider=new TxtFormatProvider();
string plainText = provider.Export(fragment.ToDocument());
this.radRichTextBox.InsertFragment(new DocumentFragment(provider.Import(plainText)));
e.Cancel = true;
}
}
}
Related threads:
- How to paste plain text http://www.telerik.com/forums/paste-plain-text
- How to remove hyperlinks http://www.telerik.com/forums/remove-hyperlinks-when-executing-pastecommand
- Preventing paste of images http://www.telerik.com/forums/limiting-the-radrichtextbox (Silverlight)