DataRequestedEventArgs class

Applies to Windows and Windows Phone

Contains information about the DataRequested event. The system fires this event when the user invokes the Share UI.

Syntax


public sealed class DataRequestedEventArgs

Attributes

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

Members

The DataRequestedEventArgs class has these types of members:

Properties

The DataRequestedEventArgs class has these properties.

PropertyAccess typeDescription

Request

Read-onlyEnables you to get the DataRequest object and either give it data or a failure message.

 

Remarks

To share content from one app to another, a user invokes the Share UI. The most common way to do this is through the charms, although you can use the DataTransferManager class to launch the UI programmatically. When the Share UI launches, the system fires a datarequested event. The object included with this event is an instance of the DataRequestedEventArgs class.

This event has one property, request. This property contains an instance of the DataRequest class, which your app uses to supply the content the user wants to share with the target app.

Examples


//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