Information
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

Applies to Windows and Windows Phone

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.

Syntax


var shareOperation = promise.operation;

Attributes

[MarshalingBehavior(Standard)]
[Version(0x06020000)]

Members

The ShareOperation class has these types of members:

Methods

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

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

 

Properties

The ShareOperation class has these properties.

PropertyAccess typeDescription

Data

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

QuickLinkId

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

 

Remarks

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

Examples

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


var shareOperation = eventObject.detail.shareOperation;
if (shareOperation.data.contains(Windows.ApplicationModel.DataTransfer.StandardDataFormats.text)) {
    shareOperation.data.getTextAsync().done(function (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

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]

Namespace

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

Metadata

Windows.winmd

See also

Sharing content source app sample
Sharing content target app sample
Quickstart: Sharing content (HTML)
Quickstart: Sharing content (XAML)
Quickstart: Receiving shared content (HTML)
Quickstart: Receiving shared content (XAML)

 

 

Show:
© 2014 Microsoft