DataRequest.Data | data property

Applies to Windows and Windows Phone

Sets or gets a DataPackage object that contains the content a user wants to share.

Syntax


var data = dataRequest.data;
dataRequest.data = data;

Property value

Type: DataPackage

Contains the content a user wants to share.

Remarks

The Data property enables your app to supply data to a target app. Your app must supply this data by using a DataPackage object.

Use this property when your app has the content immediately available that the user wants to share. If you need to call a function to generate the DataPackage, use the GetDeferral method.

When your app cannot supply a DataPackage object, use the FailWithDisplayText method to cancel the share and provide a message that the target app can display to the user.

Examples

The following code shows how to get a DataPackage object from the Data property as part of setting the data on a DataPackage to share with another app.


function registerForShare() {
    var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
    dataTransferManager.addEventListener("datarequested", shareTextHandler);
}

function shareTextHandler(e) {
    var request = e.request;
    request.data.properties.title = "Share Text Example";
    request.data.properties.description = "A demonstration that shows how to share.";
    request.data.setText("Hello World!");
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

See also

DataRequest

 

 

Show:
© 2014 Microsoft. All rights reserved.