Gets and sets information from the clipboard object.
Syntax
var clipboard = Windows.ApplicationModel.DataTransfer.Clipboard;
Attributes
- DualApiPartitionAttribute()
- MarshalingBehaviorAttribute(Standard)
- StaticAttribute(Windows.ApplicationModel.DataTransfer.IClipboardStatics, NTDDI_WIN8)
- VersionAttribute(NTDDI_WIN8)
Members
The Clipboard class has these types of members:
Events
The Clipboard class has these events.
| Event | Description |
|---|---|
| ContentChanged | Occurs when the data stored in the Clipboard changes. |
Methods
The Clipboard class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| Clear | Removes all data from the Clipboard. |
| Flush | Adds the content to the Clipboard and releases the DataPackage object from the source app. This method allows the content to remain available after the application shuts down. |
| GetContent | Gets the current content that is stored in the clipboard object. |
| SetContent | Sets the current content that is stored in the clipboard object. |
Remarks
Because the Clipboard class is a static class, you don't need to create an instance of it to access its methods.
Note : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
Examples
The following sample shows how to track changes to the Clipboard. If the Clipboard has text, the code adds the text to an HTML page.
Windows.ApplicationModel.DataTransfer.Clipboard.addEventListener("contentchanged", function (event) { var dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.getContent(); if (dataPackageView.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) { dataPackageView.getTextAsync().then(function (text) { // To output the text from this example, you need an HTML element // with an id of "output". document.getElementById("output").innerText = "Clipboard now contains: " + text; }); } });
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps, desktop apps] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps, desktop apps] |
|
Namespace |
|
|
Metadata |
|
Build date: 2/25/2013