DataPackageView DataPackageView DataPackageView DataPackageView DataPackageView Class

Definition

A read-only version of a DataPackage. Apps that receive shared content get this object when acquiring content.

public : sealed class DataPackageView : IDataPackageView, IDataPackageView2, IDataPackageView3, IDataPackageView4
struct winrt::Windows::ApplicationModel::DataTransfer::DataPackageView : IDataPackageView, IDataPackageView2, IDataPackageView3, IDataPackageView4
public sealed class DataPackageView : IDataPackageView, IDataPackageView2, IDataPackageView3, IDataPackageView4
Public NotInheritable Class DataPackageView Implements IDataPackageView, IDataPackageView2, IDataPackageView3, IDataPackageView4
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following code shows how you can use the DataPackageView to get the text being shared. For this example to work properly, you need to add code that detects if your app was launched in response to a share operation. See our topic, How to receive text to learn more.

var shareOperation = eventObject.detail.shareOperation;
if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) {
    shareOperation.data.getTextAsync().done(function (text) {
            // To output the text using this example, 
            // you need a div tag with an id of "output" in your HTML file.
            document.getElementById("output").innerText = text;
        }, function (e) {
            displayError("Error retrieving Text format: " + e);
        }
    });
}

Remarks

During a share operation, the source app puts the data being shared in a DataPackage object and sends that object to the target app for processing. The DataPackage class includes a number of methods to support the following default formats: text, Rtf, Html, Bitmap, and StorageItems. It also has methods to support custom data formats. To use these formats, both the source app and target app must already be aware that the custom format exists.

Target apps can use the DataPackageView object to acquire the data being shared. In addition, these apps can use the AvailableFormats property to identify what formats the DataPackageView supports, or the Contains method to query for a specific format.

Source apps have the option of using the SetDataProvider to assign a delegate to a DataPackage, instead of providing the data immediately. This process is useful in situations where the source app supports a given format but does not want to generate the data unless the target app requests it. For example, a source app might support a variety of image formats for sharing photos. Instead of creating multiple copies of each image using these formats, the source app can use a delegate that is called when the target app requests a specific format type.

Properties

AvailableFormats AvailableFormats AvailableFormats AvailableFormats AvailableFormats

Returns the formats the DataPackageView contains.

Properties Properties Properties Properties Properties

Gets a DataPackagePropertySetView object, which contains a read-only set of properties for the data in the DataPackageView object.

RequestedOperation RequestedOperation RequestedOperation RequestedOperation RequestedOperation

Gets the requested operation (such as copy or move). Primarily used for Clipboard actions.

Methods

Contains(String) Contains(String) Contains(String) Contains(String) Contains(String)

Checks to see if the DataPackageView contains a specific data format.

GetApplicationLinkAsync() GetApplicationLinkAsync() GetApplicationLinkAsync() GetApplicationLinkAsync() GetApplicationLinkAsync()

Gets the application link in the DataPackageView object.

GetBitmapAsync() GetBitmapAsync() GetBitmapAsync() GetBitmapAsync() GetBitmapAsync()

Gets the bitmap image contained in the DataPackageView

GetDataAsync(String) GetDataAsync(String) GetDataAsync(String) GetDataAsync(String) GetDataAsync(String)

Gets the data contained in the DataPackageView.

GetHtmlFormatAsync() GetHtmlFormatAsync() GetHtmlFormatAsync() GetHtmlFormatAsync() GetHtmlFormatAsync()

Gets the HTML stored in the DataPackageView object.

GetResourceMapAsync() GetResourceMapAsync() GetResourceMapAsync() GetResourceMapAsync() GetResourceMapAsync()

Gets the data (such as an image) referenced in HTML content.

GetRtfAsync() GetRtfAsync() GetRtfAsync() GetRtfAsync() GetRtfAsync()

Gets the rich text formatted (RTF) content contained in a DataPackageView.

GetStorageItemsAsync() GetStorageItemsAsync() GetStorageItemsAsync() GetStorageItemsAsync() GetStorageItemsAsync()

Gets the files and folders stored in a DataPackageView object.

GetTextAsync() GetTextAsync() GetTextAsync() GetTextAsync() GetTextAsync()

Gets the text in the DataPackageView object.

GetTextAsync(String) GetTextAsync(String) GetTextAsync(String) GetTextAsync(String) GetTextAsync(String)

Gets the text in the DataPackageView object.

GetUriAsync() GetUriAsync() GetUriAsync() GetUriAsync() GetUriAsync()

Note

GetUriAsync may be altered or unavailable for releases after Windows 8.1. Instead, use GetApplicationLink or GetWebLink.

Gets the URI contained in the DataPackageView.

GetWebLinkAsync() GetWebLinkAsync() GetWebLinkAsync() GetWebLinkAsync() GetWebLinkAsync()

Gets the web link in the DataPackageView object.

ReportOperationCompleted(DataPackageOperation) ReportOperationCompleted(DataPackageOperation) ReportOperationCompleted(DataPackageOperation) ReportOperationCompleted(DataPackageOperation) ReportOperationCompleted(DataPackageOperation)

Informs the system that your app is finished using the DataPackageView object. Primarily used for Clipboard operations.

RequestAccessAsync() RequestAccessAsync() RequestAccessAsync() RequestAccessAsync() RequestAccessAsync()

Requests permission to unlock and access a data package that is secured with a protection policy.

RequestAccessAsync(String) RequestAccessAsync(String) RequestAccessAsync(String) RequestAccessAsync(String) RequestAccessAsync(String)

Requests permission to unlock and access a data package that is secured with a protection policy.

SetAcceptedFormatId(String) SetAcceptedFormatId(String) SetAcceptedFormatId(String) SetAcceptedFormatId(String) SetAcceptedFormatId(String)

Sets the accepted format Id.

UnlockAndAssumeEnterpriseIdentity() UnlockAndAssumeEnterpriseIdentity() UnlockAndAssumeEnterpriseIdentity() UnlockAndAssumeEnterpriseIdentity() UnlockAndAssumeEnterpriseIdentity()

Unlocks a data package and assumes an enterprise identity for it.

See Also