Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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


public sealed class DataRequest

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.


//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!");
}


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