Occurs when a share operation starts.
Syntax
function onDataRequested(eventArgs) { /* Your code */ } // addEventListener syntax dataTransferManager.addEventListener("datarequested", onDataRequested); dataTransferManager.removeEventListener("datarequested", onDataRequested); - or - dataTransferManager.ondatarequested = onDataRequested;
Event information
| Delegate | TypedEventHandler<DataTransferManager, DataRequestedEventArgs> |
|---|
Remarks
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.
Examples
This example uses an inline function to handle a datarequested event.
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!"); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 2/25/2013