locked
Drop from Microsoft Word RRS feed

  • Question

  • Hi!

    I have a Silverlight 2 Application and want to enable my users to insert Microsoft Word formatted Text into it. Actually I use a third party Rich TextBox. But the vendor of it says, that he will not support any Word compatibility.

    So I thought the users could paste their Word content into a UserControl that is under my control and I do add everything (incl. styles) to the RTB programmatically. But on pasting it to my control I only get the plain Text and not the formattings.

    Another idea was that the user could drag from Word and drop it into my application... Do you think this is possible and might work?

    Thanks and Greetings!

    Monday, July 20, 2009 8:28 AM

Answers

  • Take a look at using the HTML bridge to access the browsers clipboard, see something like http://weblogs.asp.net/manishdalal/archive/2008/11/19/cross-browser-clipboard-datagrid-with-excel-support-part-2.aspx
    Tuesday, July 21, 2009 4:12 PM

All replies

  • If you check out the clipboard formats you'll see that Word sets a large number of formats, the default will probably be plain text if that's all you attempt to fetch. But if you look at the other formats you'll see a (ahem) rich set of choices.
    Monday, July 20, 2009 6:48 PM
  • Thank you! Sounds great!

    How can I get one of these other formats in Silverlight?

    Tuesday, July 21, 2009 2:49 AM
  • Take a look at using the HTML bridge to access the browsers clipboard, see something like http://weblogs.asp.net/manishdalal/archive/2008/11/19/cross-browser-clipboard-datagrid-with-excel-support-part-2.aspx
    Tuesday, July 21, 2009 4:12 PM
  •  Thank you pkr2000! But Excel copys the cells with \t and \r\n to the clipboard, any other formattings are lost as well.

     I discovered that the problem is, that javascript only supports the clipboard formats 'text', 'html' and 'image'. I need 'ENHMETAFILE' or as flash calls it: 'rich text'. And here starts my hope: Flash supports the format which contains the stylings. Is there a way to use Flash to get these contents and transfere it to Silverlight? I only found ways to use flash to SET the clippboard...

    Wednesday, July 22, 2009 10:30 AM
  • I've checked my demo and unfortunately it was in WPF not SL :( But I do remember that there is indeed a Flash component that is there for no other reason than to offer clipboard support. http://www.jeff.wilcox.name/2008/05/clipboard-access/ I feel bad that I said it could be done in SL, that darn WPF is too close to SL, sorry!
    Wednesday, July 22, 2009 7:12 PM