Dela via


DataRequest Class

Definition

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

public ref class DataRequest sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DataRequest final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DataRequest
Public NotInheritable Class DataRequest
Inheritance
Object Platform::Object IInspectable DataRequest
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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

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.

Properties

Data

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

Deadline

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

Methods

FailWithDisplayText(String)

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.

Applies to