locked
Windows store app - Copy text to clipboard RRS feed

  • Question

  • How do i  copy text to a clipboard? For example. If a user clicks a button, the app should copy "Text Copied" to the user's clipboard so they can paste it in another app.
    Thursday, October 24, 2013 1:07 PM

Answers

  • This should do the trick:

    var dataPackage = new DataPackage();
    dataPackage.SetText("Your copied text here.");
    
    try
    {
        Clipboard.SetContent(dataPackage);
    }
    catch (Exception ex)
    {
        // Error handling here
    }

    Thursday, October 24, 2013 1:15 PM