locked
Add Image to Richtextbox from ClipBoard RRS feed

  • Question

  • Hello,

    i wan´t to add a Image from clipboard to my richtextbox.

    i try something. but i don´t know how to add the image.

     

    private asyncvoidPaste(RichEditBoxbox)

    {

    var dataPackage = Clipboard.GetContent(); if (dataPackage.Contains(StandardDataFormats.Text)) { box.Document.Selection.Text = await dataPackage.GetTextAsync(); } else if (dataPackage.Contains(StandardDataFormats.Html)) { // handle the HTML content } else if (dataPackage.Contains(StandardDataFormats.Bitmap)) { var t = await dataPackage.GetBitmapAsync(); var t2 = await t.OpenReadAsync(); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(t2); Image image = new Image(); image.Source = bitmapImage; } else if (dataPackage.Contains(StandardDataFormats.StorageItems)) { // handle the file content }



    Wednesday, June 5, 2013 7:51 PM

Answers

  • You have to add the RTF which describes the image to the existing text of the richeditbox.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, June 6, 2013 7:22 PM
    Moderator

All replies

  • You have to add the RTF which describes the image to the existing text of the richeditbox.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, June 6, 2013 7:22 PM
    Moderator
  • can you make a sample for me? i dont understand what you mean.

    Wednesday, June 12, 2013 4:45 PM