Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Set Clipboard Text Programmatically in Windows Phone

DZone's Guide to

How to Set Clipboard Text Programmatically in Windows Phone

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

If you have to set the Clipboard text programmatically in your Windows Phone, you can use the Clipboard Class that is defined in the System.Windows Namespace.

Clipboard is a static class that exposes 3 properties

1. ContainsText

2. GetText

3. SetText

How to Set Clipboard text (Copy Paste) programmatically in Windows Phone?

You can use the Clipboard.SetText to set the text for the clipboar.

Clipboard.SetText("www.windowsphonerocks.com");

There is also a restriction to use the Clipboard.GetText which results in the SecurityException.

To test if the Clipboard has the value that you set, just paste the data to a textbox after using the Clipboard.SetText

Related Articles:

 

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Senthil Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}