Clipboard.ContentChanged Event

Definition

Occurs when the data stored in the Clipboard changes.

// Register
static event_token ContentChanged(EventHandler<IInspectable> const& handler) const;

// Revoke with event_token
static void ContentChanged(event_token const* cookie) const;

// Revoke with event_revoker
static Clipboard::ContentChanged_revoker ContentChanged(auto_revoke_t, EventHandler<IInspectable> const& handler) const;
public static event System.EventHandler<object> ContentChanged;
function onContentChanged(eventArgs) { /* Your code */ }
Windows.ApplicationModel.DataTransfer.Clipboard.addEventListener("contentchanged", onContentChanged);
Windows.ApplicationModel.DataTransfer.Clipboard.removeEventListener("contentchanged", onContentChanged);
- or -
Windows.ApplicationModel.DataTransfer.Clipboard.oncontentchanged = onContentChanged;
Public Shared Custom Event ContentChanged As EventHandler(Of Object) 

Event Type

EventHandler<Object>

EventHandler<Object>

EventHandler<IInspectable>

Examples

The following example shows how to track changes to the Clipboard. The first code snippet registers a handler for the ContentChanged event. The second code snippet shows the event handler, which enables the app's paste command if the Clipboard contains a bitmap.

function RegisterEvents() {

    // Register a listener for the ContentChanged event. It is called whenever 
    // the clipboard content changes
    Windows.ApplicationModel.DataTransfer.Clipboard.addEventListener(
        "contentchanged", onClipboardContentChanged); 

// TODO: Register other event listeners here.

}
function onClipboardContentChanged(e) {
    var dataPackageView = Windows.ApplicationModel.DataTransfer.Clipboard.getContent();
    if (dataPackageView.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.bitmap)) {
        // TODO: Enable the Paste command.

    }
}

Remarks

This event is helpful in situations when your app contains logic that varies depending on the contents on the clipboard. For example, your app might include a Paste button, which is disabled unless the Clipboard contains content.

Applies to