Provides static methods that facilitate transferring data to and from the system Clipboard.
Assembly: PresentationCore (in PresentationCore.dll)
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 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.
// For this example, the data to be placed on the clipboard is a simple // string. string textData = "I want to put this string on the clipboard."; // After this call, the data (string) is placed on the clipboard and tagged // with a data format of "Text". Clipboard.SetData(DataFormats.Text, (Object)textData);
For a more complete sample, see Clipboard Spy Sample.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.