DataRequestedEventArgs DataRequestedEventArgs DataRequestedEventArgs DataRequestedEventArgs Class

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

Syntax

Declaration

public sealed class DataRequestedEventArgspublic sealed class DataRequestedEventArgsPublic NotInheritable Class DataRequestedEventArgs

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

Properties summary

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

Properties

  • Request
    Request
    Request
    Request

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

    public DataRequest Request { get; }public DataRequest Request { get; }Public ReadOnly Property Request As DataRequest

    Property Value

    Remarks

    When a user invokes the Share UI to share content, the system fires a DataRequested event. The request property of the event contains a DataRequest object, which lets your app supply the information the user wants to share.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute

Details

Assembly

Windows.ApplicationModel.DataTransfer.dll