DataRequest class

Applies to Windows and Windows Phone

Lets your app supply the content the user wants to share or specify a message, if an error occurs.

Syntax


/* For information about creating or accessing this object, see Remarks. */

Attributes

[MarshalingBehavior(Agile)]
[Muse()]
[Version(0x06020000)]

Members

The DataRequest class has these types of members:

Methods

The DataRequest class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
FailWithDisplayText Cancels the sharing operation and supplies an error string to display to the user.
GetDeferral Supports asynchronous sharing operations by creating and returning a DataRequestDeferral object.

 

Properties

The DataRequest class has these properties.

PropertyAccess typeDescription

Data

Read/writeSets or gets a DataPackage object that contains the content a user wants to share.

Deadline

Read-onlyGets the deadline for finishing a delayed rendering operation. If execution goes beyond that deadline, the results of delayed rendering are ignored.

 

Remarks

Your app receives a DataRequest object when a datarequested event occurs. With this object, your app can supply data to a target app by using a DataPackage object, use a deferral object to call a function, or inform the target app that an error occurred.

Examples

The following code shows how to use the DataRequest object 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 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8

Namespace

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

Metadata

Windows.winmd

 

 

Show:
© 2014 Microsoft