Clipboard API in Windows Phone

Clipboard API in Windows Phone

Windows Phone by default provides the inbuilt mechanism to support Clipboard Copy, Paste functionalities and shows the proper icon in any TextBox control. But in some case, you may need to handle the copy experience explicitly.


This small post will discuss about the API and the code that you can use in your Windows Phone application. Continue reading.


As I said above, the Clipboard functionality is already handled by the operating system in all Windows Phone devices and you don’t have to write a single piece of code normally if it is inside a TextBox or Password box control. But sometime, it is require to provide copy functionality in a List or a View. As you can not paste outside a input box and the OS already handles that, there are no need to handle this operation by code.


The Windows Phone SDK provides a class named “Clipboard” present under “System.Windows” namespace and exposes three methods named “ContainsText()”, “GetText()” and “SetText(string text)”.


    • ContainsText() - Queries the clipboard for the presence of data in the UnicodeText format and returns true or false.
    • GetText() - If Unicode text data is present on the system clipboard, returns a string that contains the Unicode text data. Otherwise, returns an empty string. You can not directly call this API method.
    • SetText(string text) - Sets Unicode text data to store on the clipboard.


An exception of type 'System.Security.SecurityException' occurred in but was not handled in user code


Please remember that, if you give call to Clipboard.GetText() method, it will throw a SecurityException with the following message: “An exception of type 'System.Security.SecurityException' occurred in but was not handled in user code”. Hope, this helps.


If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Twitter, Facebook, Google+ and LinkedIn. I would love to hear your thoughts and opinions on my articles directly. Also, don't forget to share your views and/or feedback in the comment section below.


  1. Thank you very much. Much needed one:)

  2. how to clear clipboard in windows phone 8

  3. How i can copy and paste the textblock text in application. this is only for Textbox text .

  4. Thank you Sir Your Reply.Now I am able to copy the Textblock Text but i am unable to paste that text anywhere.My requierment is i need to copy the textblock text and paste that text in anyplace of Application or outside the application.So please help me to do this.

  5. can i use this clipboard in windows phone 8.1


© 2008-2018 - Microsoft Technology Blog for developers and consumers | Designed by Kunal Chowdhury
Back to top