Clipboard.ContentChanged イベント

定義

クリップボードに格納されているデータが変更されたときに発生します。

// 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) 

イベントの種類

次の例は、クリップボードへの変更を追跡する方法を示 しています。 最初のコード スニペットは、ContentChanged イベントのハンドラーを登録します。 2 番目のコード スニペットは、TextBlock コントロールのクリップボードのテキストコンテンツを表示するイベント ハンドラーを示しています。

Clipboard.ContentChanged += new EventHandler<object>(this.TrackClipboardChanges_EventHandler);
private async void TrackClipboardChanges_EventHandler(object sender, object e)
{
    DataPackageView dataPackageView = Clipboard.GetContent();
    if (dataPackageView.Contains(StandardDataFormats.Text))
    {
        String text = await dataPackageView.GetTextAsync();

        // To output the text from this example, you need a TextBlock control
        // with a name of "TextOutput".
        TextOutput.Text = "Clipboard now contains: " + text;
    }
}

注釈

このイベントは、クリップボードの内容によって異なるロジックがアプリに含まれている場合に役立ちます。 たとえば、クリップボードにコンテンツが含まれている場合を除き、アプリに [貼り付け] ボタンが含まれている場合があります。

適用対象