Can I paste an image from the clipboard?

5 posts, 0 answers
  1. Rick
    Rick avatar
    1 posts
    Member since:
    Mar 2011

    Posted 07 Mar 2011 Link to this post

    Does the RichTextBox control support pasting images from the clipboard? If not, will it in a future version? Also, if this isn't currently possible, what is the most seemless way to get images into the control - does it require saving the image to disk first?
  2. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 08 Mar 2011 Link to this post

    The only format supported by the Silverlight clipboard is plain text. This means that not even rich text can be pasted from, say, MS Word or a web page with the formatting retained. But this is a limitation in Silverlight and not in the Telerik RichTextBox. If you use the built-in "Insert Image" function in the RichTextBox, the images will be inserted inline in the xaml as base64-encoded strings.
  3. DevCraft banner
  4. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 10 Mar 2011 Link to this post

    Hello Rick,

    Henrik is absolutely right - thanks for providing such an accurate answer, Henrik.
    What I can add is that images can be inserted through a dialog, similar to the way images are embedded in MS Word. They can also be included in code, using ImageInline or an InlineUIContainer containing an Image. If you use ImageInline with an absolute URI for UriSource, you have to make sure that the URI is for a page with permissive cross-domain policy.
    Copy/Paste of rich text and images inside RadRichTextBox is supported through an internal clipboard.
    If you encounter any difficulties with your scenario, you can get back to us with some details on the problem.

    Kind regards,
    Iva
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  5. Samuel
    Samuel avatar
    3 posts
    Member since:
    Sep 2011

    Posted 05 Oct 2011 Link to this post

    If you use the built-in "Insert Image" function in the RichTextBox, the images will be inserted inline in the xaml as base64-encoded strings.

    Can I please have a step by step explanation for this? If you have an example code that will be great.

    Appreciate your help!
  6. Boby
    Admin
    Boby avatar
    595 posts

    Posted 11 Oct 2011 Link to this post

    Hello Samuel,
    You just have to use the RadRichTextBox.InsertImage(Stream imageStream, string extension) method, for example:
    OpenFileDialog ofd = new OpenFileDialog();
    ofd.Filter = "Image Files (*.bmp, *.jpg, *.jpeg, *.png)|*.bmp;*.jpg;*.jpeg;*.png";
     
    if (ofd.ShowDialog() == true)
    {
        string extension = ofd.File.Extension;
     
        using (Stream imageStream = ofd.File.OpenRead())
        {
            this.AssociatedRichTextBox.InsertImage(imageStream, extension);
        }
    }


    Best wishes,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner