DataTransferManager.DataRequested DataTransferManager.DataRequested DataTransferManager.DataRequested DataTransferManager.DataRequested DataTransferManager.DataRequested Event


Occurs when a share operation starts.

public : event TypedEventHandler<DataTransferManager, DataRequestedEventArgs> DataRequested
// Register
event_token DataRequested(TypedEventHandler<DataTransferManager, DataRequestedEventArgs> const& handler) const;

// Revoke with event_token
void DataRequested(event_token const& cookie) const;

// Revoke with event_revoker
DataRequested_revoker DataRequested(auto_revoke_t, TypedEventHandler<DataTransferManager, DataRequestedEventArgs> const& handler) const;
public event TypedEventHandler<DataTransferManager, DataRequestedEventArgs> DataRequested
Public Event DataRequested As TypedEventHandler (Of DataTransferManager, DataRequestedEventArgs)
function onDataRequested(eventArgs){/* Your code */}

dataTransferManager.addEventListener("datarequested", onDataRequested);
dataTransferManager.removeEventListener("datarequested", onDataRequested);


This example uses an inline function to handle a datarequested event.

//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!");
function registerForShare() {
    var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
    dataTransferManager.addEventListener("datarequested", shareTextHandler);

function shareTextHandler(e) {
    var request = e.request; = "Share Text Example"; = "A demonstration that shows how to share.";"Hello World!");


This event is fired when a sharing operation starts— typically when the user taps the Share charm, although it is also fired if your app starts a share operation programmatically. To handle this event, you need to add an event listener to the DataTransferManager object for the active window. You can get this object through the GetForCurrentView method.

When handling a datarequested event, the most important property you need to be aware of is its request property. This property contains a DataRequest object. Your app uses this object to provide the data that the user wants to share with a selected target app.