DataRequestedEventArgs Class

Definition

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

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

Windows requirements

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

Examples

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

When you use the DataTransferManager class to launch the Share UI programmatically, 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.

Properties

Request

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

Applies to