DataTransferManager class
Programmatically initiates an exchange of content with other apps.
Syntax
public ref class DataTransferManager sealed : Object
Attributes
- MarshalingBehaviorAttribute(Standard)
- MuseAttribute()
- StaticAttribute(Windows.ApplicationModel.DataTransfer.IDataTransferManagerStatics, NTDDI_WIN8)
- VersionAttribute(NTDDI_WIN8)
Members
The DataTransferManager class has these types of members:
Events
The DataTransferManager class has these events.
| Event | Description |
|---|---|
| DataRequested | Occurs when a share operation starts. |
| TargetApplicationChosen | Occurs when the user chooses a target app in the Share charm. |
Methods
The DataTransferManager class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| GetForCurrentView | Returns the DataTransferManager object associated with the current window. |
| ShowShareUI | Programmatically initiates the user interface for sharing content with another app. |
Remarks
The DataTransferManager class is a static class that you use to initiate sharing operations. To use the class, first call the GetForCurrentView method. This method returns the DataTransferManager object that is specific to the active window. Next, you need to add an event listener for the datarequested event to the object. 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.
The DataTransferManager class includes a ShowShareUI method, which you can use to programmatically start a share operation. In general, we recommend against using this method. Users expect to initiate share operations by using the Share charm—when you launch the operation programmatically, you can create an inconsistent user experience. We include the method because there are a few scenarios in which the user might not recognize opportunities to share. A good example is when the user achieves a high score in a game.
The DataTransferManager class also has a TargetApplicationChosen event. Use this event when you want to capture what applications a user selects when sharing content from your app.
Note : This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).
Windows Phone 8
This API is supported in native apps only.
Examples
This example shows a typical way of using the DataTransferManager object.
function setupShare() {
var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView();
dataTransferManager.addEventListener("datarequested", function (e) {
var request = e.request;
request.data.properties.title = "Share Demonstration";
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 |
|
|
Metadata |
|
Build date: 2/25/2013
