Export (0) Print
Expand All

Clipboard Class

Provides static methods that facilitate transferring data to and from the system Clipboard.

System::Object
  System.Windows::Clipboard

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

public ref class Clipboard abstract sealed

The Clipboard type exposes the following members.

  NameDescription
Public methodStatic memberClearClears any data from the system Clipboard.
Public methodStatic memberContainsAudioQueries the Clipboard for the presence of data in the WaveAudio data format.
Public methodStatic memberContainsDataQueries the Clipboard for the presence of data in a specified data format.
Public methodStatic memberContainsFileDropListQueries the Clipboard for the presence of data in the FileDrop data format.
Public methodStatic memberContainsImageQueries the Clipboard for the presence of data in the Bitmap data format.
Public methodStatic memberContainsText()Queries the Clipboard for the presence of data in the UnicodeText format.
Public methodStatic memberContainsText(TextDataFormat)Queries the Clipboard for the presence of data in a text data format.
Public methodStatic memberFlushPermanently adds the data that is on the Clipboard so that it is available after the data's original application closes.
Public methodStatic memberGetAudioStreamReturns a stream of Clipboard data in the WaveAudio data format.
Public methodStatic memberGetDataRetrieves data in a specified format from the Clipboard.
Public methodStatic memberGetDataObjectReturns a data object that represents the entire contents of the Clipboard.
Public methodStatic memberGetFileDropListReturns a string collection that contains a list of dropped files available on the Clipboard.
Public methodStatic memberGetImageReturns a BitmapSource object from the Clipboard that contains data in the Bitmap format.
Public methodStatic memberGetText()Returns a string containing the UnicodeText data on the Clipboard.
Public methodStatic memberGetText(TextDataFormat)Returns a string containing text data on the Clipboard.
Public methodStatic memberIsCurrentCompares a specified data object to the contents of the Clipboard.
Public methodStatic memberSetAudio(array<Byte>)Stores audio data (WaveAudio data format) on the Clipboard. The audio data is specified as a byte array.
Public methodStatic memberSetAudio(Stream)Stores audio data (WaveAudio data format) on the Clipboard. The audio data is specified as a stream.
Public methodStatic memberSetDataStores the specified data on the Clipboard in the specified format.
Public methodStatic memberSetDataObject(Object)Places a specified non-persistent data object on the system Clipboard.
Public methodStatic memberSetDataObject(Object, Boolean)Places a specified data object on the system Clipboard and accepts a Boolean parameter that indicates whether the data object should be left on the Clipboard when the application exits.
Public methodStatic memberSetFileDropListStores FileDrop data on the Clipboard. The dropped file list is specified as a string collection.
Public methodStatic memberSetImageStores Bitmap data on the Clipboard. The image data is specified as a BitmapSource.
Public methodStatic memberSetText(String)Stores UnicodeText data on the Clipboard.
Public methodStatic memberSetText(String, TextDataFormat)Stores text data on the Clipboard in a specified text data format. The UnicodeText data to store is specified as a string.
Top

All applications for Windows share the system Clipboard, so the contents are subject to change when you switch to another application.

For a list of predefined formats available to use with the Clipboard class, see the DataFormats class.

Security Alert: For security purposes, the following points should be kept in mind.

  • Paste operations need to be user initiated (Ctrl-V, Paste Menu).

  • Copy can only be on user selected content.

  • On copy or cut, partial trust code puts plaintext and Extensible Application Markup Language (XAML) on to the clipboard. Plaintext includes text, Unicode text, OEM (Object Exchange Model) text, and CSV (Comma-separated values).

  • On paste, Windows Presentation Foundation (WPF) will paste in Extensible Application Markup Language (XAML) if the source of that content is from a equally trusted or more trusted site. Specifically:

    • A partial trust application can paste Extensible Application Markup Language (XAML) from a full trust application.

    • A partial trust application can paste Extensible Application Markup Language (XAML) from a partial trust application.

    • A full trust application can paste XAML only from another fully trusted application.

    • A non-Windows Presentation Foundation (WPF) full trust application can examine the ApplicationTrust format on the clipboard and sanitize the XAML if appropriate.

The following example shows how to add data to the system Clipboard.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft