Silverlight 4 – Clipboard Access

Silverlight 4 introduces a new API for accessing the  clipboard through  3 static methods – GetText(), SetText(), ContainsText() . Using these methods is very simple, for example to test if there is anything on the clipboard and then paste it to a text box.

if (Clipboard.ContainsText())

{

txtText.Text = Clipboard.GetText();
}

To place text on the clipboard:

Clipboard.SetText(txtText.Text);

Silverlight can only access the clipboard  from a user initiated action (such as from the mouse or keyboard) after performing this action the user is prompted to acknowledge the app is accessing the clipboard, this occurs only once per session.

This entry was posted in FAQ and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>