Windows desktop applications
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ShareOperation class

Handles the bulk of the work during a share operation. This includes the data that the user wants to share, setting or removing QuickLinks, and informing the system about the status of the operation.


var shareOperation = promise.operation;


The ShareOperation class has these types of members:


The ShareOperation class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

DismissUI Closes the share pane.
RemoveThisQuickLink Removes the QuickLink from the list of QuickLinks that are available to the user.
ReportCompleted Specifies that the sharing operation is complete.
ReportCompleted(QuickLink) Specifies that the sharing operation is complete. A QuickLink that the system can save as a shortcut for future sharing operations is included.
ReportDataRetrieved Specifies that the app has acquired the content that the user wants to share.
ReportError Specifies that an error occurred during the sharing operation.
ReportStarted Specifies that the app has started to acquire the content that the user wants to share.
ReportSubmittedBackgroundTask Specifies that the app has requested that the system allow the sharing operation to run as a background task.



The ShareOperation class has these properties.

PropertyAccess typeDescription


Read-onlyContains a DataPackage object with the data that the user wants to share.


Read-onlyA string that contains the ID of a QuickLink.



When a user selects your app as the target of a share action, an activated event fires. The object that this event sends to your app contains the instance of the ShareOperation class.

An app currently open as a Share target cannot initiate an additional ShareOperation, or launch a FileOpenPicker or FileSavePicker.

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).


The following example shows how to work with the ShareOperation object.

var shareOperation = eventObject.detail.shareOperation;
if ( { (text) {
            // To output the text using this example, 
            // you need a div tag with an id of "output" in your HTML file.
            document.getElementById("output").innerText = text;
        }, function (e) {
            displayError("Error retrieving Text format: " + e);

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


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



Requirements (Windows 8.x and Windows Phone 8.x)

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.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


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





See also

Sharing content source app sample
Sharing content target app sample
Quickstart: Sharing content (HTML)
Share data
Quickstart: Receiving shared content (HTML)
Receive data



© 2016 Microsoft