locked
Highlighting and copying text from TextBlocks RRS feed

  • Question

  • Couldn't find a question like this already on the forums, thought there would be :)

    Just want to know if users will be able to highlight text in Silverlight(not just TextBlocks) and copy to clipboard. Need to know if it can't be done or it's an RTM thing. Since I do think you can do this in Flash.

    Friday, August 8, 2008 1:13 PM

Answers

  • No, nothing in Silverlight as of Silverlight 2 that provides global selection and copy functionality. You would have to write your own logic to perform "logical" selection and then use HTML dom to interact with the HTML clipboard.

    Silverlight 2 does not have clipboard APIs, only the TextBox can copy/paste from the clipboard based upon user actions. We have looked at highlighting text but there is a lot of work required to enable selection across multiple TextBlocks. In addition, some people would want to support selecting more than just text. This isn't something for Silverlight 2, but a major release after that.

    -mark
    Silverlight Program Manager
    Microsoft
    This post is provided "as-is"

    Wednesday, August 13, 2008 2:21 AM

All replies

  • This functionality is not provided by TextBlocks in Silverlight, but it is available in TextBox. TextBox can be set to be read only, so the text is not editable. The TextBox can also be re-templated, to get rid of the border around it.

    Friday, August 8, 2008 4:43 PM
  • Is the ability to highlight in the pipeline for Silverlight though? Makes it easier to highlight and copy text, Urls, Datagrid contents, etc.

     

    Edit:
    Talking to Flash guy it sounds like they also do the "textbox" trick to get text higlighted. So it sounds like that would be the only workaround :)

    Friday, August 8, 2008 5:13 PM
  • Are you trying to do select and copy in TextBox?

    if yes, see this thread (although I don't know why the other guy could not get select to work, I can):  http://silverlight.net/forums/t/22224.aspx

    Saturday, August 9, 2008 11:36 AM
  • No, just generally copying text anywhere.

    Monday, August 11, 2008 10:34 AM
  • No, nothing in Silverlight as of Silverlight 2 that provides global selection and copy functionality. You would have to write your own logic to perform "logical" selection and then use HTML dom to interact with the HTML clipboard.

    Silverlight 2 does not have clipboard APIs, only the TextBox can copy/paste from the clipboard based upon user actions. We have looked at highlighting text but there is a lot of work required to enable selection across multiple TextBlocks. In addition, some people would want to support selecting more than just text. This isn't something for Silverlight 2, but a major release after that.

    -mark
    Silverlight Program Manager
    Microsoft
    This post is provided "as-is"

    Wednesday, August 13, 2008 2:21 AM
  • Is there any new insight into this?

    I don't specifically need to copy across multiple TextBlocks, Labels, just a single one. I can of course use a disabled TextBox, but this doesn't always look the best.

    TIA

    Sunday, April 17, 2011 10:08 PM