이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

DataPackage Class

사용자가 다른 응용 프로그램과 교환하려는 데이터를 포함합니다.

구문


public sealed class DataPackage : Object

특성

ActivatableAttribute(NTDDI_WIN8)
DualApiPartitionAttribute()
MarshalingBehaviorAttribute(Agile)
VersionAttribute(NTDDI_WIN8)

구성원

DataPackage클래스에는 다음과 같은 유형의 구성원이 있습니다.

생성자

DataPackage클래스에는 다음 생성자가 있습니다.

생성자설명
DataPackage Constructor that creates a new DataPackage.

 

이벤트

DataPackage클래스에는 다음 이벤트가 있습니다.

이벤트설명
Destroyed Occurs when the DataPackage is destroyed.
OperationCompleted Occurs when a paste operation is completed.

 

메서드

The DataPackage 클래스 다음 메서드가 있습니다. C#, Visual Basic 및 C++에서는 다음에서 메서드를 상속합니다. Object 클래스.

메서드설명
GetView Returns a DataPackageView object. This object is a read-only copy of the DataPackage object.
SetBitmap Sets the bitmap image contained in the DataPackage.
SetData Sets the data contained in the DataPackage in a RandomAccessStream format.
SetDataProvider Sets a delegate to handle requests from the target app.
SetHtmlFormat Adds HTML content to the DataPackage.
SetRtf Sets the Rich Text Format (RTF) content that is contained in a DataPackage.
SetStorageItems(IIterable(IStorageItem)) Sets the files and folders contained in a DataPackage.
SetStorageItems(IIterable(IStorageItem), Boolean) Adds files and folders to a DataPackage.
SetText Sets the text that a DataPackage contains.
SetUri Sets the Uniform Resource Identifier (URI) that is contained in the DataPackage.

 

속성

DataPackage클래스 다음 속성이 있습니다.

속성액세스 유형설명

Properties

읽기 전용Allows you to get and set properties like the title of the content being shared.

RequestedOperation

읽기/쓰기Specifies the DataPackageOperation (none, move, copy, or link) for the operation.

ResourceMap

읽기 전용Maps a URI to a file. Used to ensure that referenced content (such as an image) in HTML content is added to the DataPackage.

 

설명

공유 작업 중에 소스 앱은 공유되는 데이터를 DataPackage 개체에 넣고 처리를 위해 이 개체를 대상 앱에 보냅니다. DataPackage 클래스에는 text, Rtf, Html, BitmapStorageItems와 같은 기본 형식을 지원하는 메서드가 포함되어 있습니다. 사용자 지정 데이터 형식을 지원하는 메서드도 있습니다. 이러한 형식을 사용하려면 원본 앱과 대상 앱이 사용자 지정 형식이 존재한다는 것을 이미 인식하고 있어야 합니다.

소스 앱에는 데이터를 즉시 제공하지 않고 대신에 SetDataProvider를 사용하여 DataPackage에 대리자를 할당할 수 있는 옵션이 있습니다. 이 프로세스는 소스 앱이 지정된 형식을 지원하지만 대상 앱이 데이터를 요청하지 않는 한 데이터를 생성하고 싶지 않을 때 유용합니다. 예를 들어 소스 앱은 사진 공유를 위한 다양한 이미지 형식을 지원할 수 있습니다. 이러한 서식을0 사용하여 각 이미지의 복사본을 여러 개 만드는 대신 원본 앱은 대상 앱이 특정 서식 형식을 요청할 때 호출되는 대리자를 사용할 수 있습니다.

대상 앱에서 DataPackageView 개체를 사용하여 공유 중인 데이터에 액세스할 수 있습니다. 또한 이러한 앱은 AvailableFormats 속성을 사용하여 DataPackageView가 지원하는 형식을 식별하거나 Contains 메서드를 사용하여 특정 형식에 대해 쿼리할 수 있습니다.

예제


//To see this code in action, add a call to ShareSouceLoad to your constructor or other
//initializing function.
private void ShareSourceLoad()
{
    DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
    dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.DataRequested);
}

private void DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
    DataRequest request = e.Request;
    request.Data.Properties.Title = "Share Text Example";
    request.Data.Properties.Description = "An example of how to share text.";
    request.Data.SetText("Hello World!");
}


요구 사항

지원되는 최소 클라이언트

Windows 8 [Windows 스토어 앱, 데스크톱 앱]

지원되는 최소 서버

Windows Server 2012 [Windows 스토어 앱, 데스크톱 앱]

지원되는 최소 전화

Windows Phone 8

네임스페이스

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

메타데이터

Windows.winmd

 

 

이 정보가 도움이 되었습니까?
(1500자 남음)
© 2013 Microsoft. All rights reserved.