SetText | setText method

DataPackage.SetText | setText method

[ Updated for UWP apps on Windows 10. For Windows 8.x articles, see the archive ]

Sets the text that a DataPackage contains.

Syntax


dataPackage.setText(value);

Parameters

value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The text.

Remarks

This method sets the text value for StandardDataFormats.Text. It's the equivalent of calling dataPackage.setText(StandardDataFormats.Text).

Text is one of the data types that the DataPackage object supports directly. See the StandardDataFormats class for information on other supported data types.

Examples


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 (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

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

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

DataPackage

 

 

Show:
© 2016 Microsoft