2 out of 3 rated this helpful - Rate this topic

DataTransferManager.GetForCurrentView | getForCurrentView method

Returns the DataTransferManager object associated with the current window.

Syntax


public static DataTransferManager GetForCurrentView()

Parameters

This method has no parameters.

Return value

Type: DataTransferManager

The DataTransferManager object associated with the current window.

Remarks

Each window has a DataTransferManager object associated with it. When sharing content, you use the GetForCurrentView method to get the DataTransferManager object that is associated with the active window. After you have the appropriate DataTransferManager object, you can add an event listener to it to handle the DataRequested event, which the system fires when a share operation is initiated. Your app uses the DataRequest object returned with this event to set the data that the user wants to share with a target app.

Examples

This example calls the GetForCurrentView method to get the DataTransferManager object associated with the active window for the app.


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


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

See also

DataTransferManager

 

 

Build date: 2/25/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.