다음을 통해 공유


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 이벤트에 대한 처리기를 등록합니다. 두 번째 코드 조각은 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;
    }
}

설명

이 이벤트는 앱에 클립보드의 내용에 따라 달라지는 논리가 포함된 경우에 유용합니다. 예를 들어 클립보드에 콘텐츠가 포함되지 않는 한 사용하지 않도록 설정된 붙여넣기 단추가 앱에 포함될 수 있습니다.

적용 대상