Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Clipboard.GetText Method

Retrieves Unicode text data from the system clipboard, if Unicode text data exists.

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

'Declaration
Public Shared Function GetText As String

Return Value

Type: System.String
If Unicode text data is present on the system clipboard, returns a string that contains the Unicode text data. Otherwise, returns an empty string.

ExceptionCondition
SecurityException

Invoked this method from outside a user-initiated context.

-or-

Clipboard access user dialog box was not confirmed.

-or-

Invoked this method in a Windows Phone application.

Under partial trust (the default mode) Silverlight restricts clipboard access to its two key APIs: GetText and SetText. These APIs can only be invoked from within a context that is determined by the Silverlight runtime to be in response to a user-initiated action. For example, clipboard access is valid from within a handler for a Click or KeyDown event. For examples of situations that are not considered user-initiated, clipboard access is not valid from a handler for Loaded, or from a constructor. Clipboard access under partial trust also requires the user to confirm access through completion of a Silverlight access confirmation dialog box.

If you specifically produce an out-of-browser application and request elevated trust, this security restriction on the API and its dialog box are not used. For more information, see Trusted Applications.

Version Notes

Silverlight for Windows Phone Silverlight for Windows Phone

You cannot get clipboard text from a Windows Phone application, only set it. Calling the GetText method in a Windows Phone application will always cause a SecurityException to occur.

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2015 Microsoft