Clipboard Class

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

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

public static class Clipboard
public final class Clipboard
public final class Clipboard
You cannot use this managed class in XAML.

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 (Ctl-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 Clipboard sample, see Clipboard Spy Sample.


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

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions