Dela via


DataPackage.SetText(String) Method

Definition

Sets the text that a DataPackage contains.

public:
 virtual void SetText(Platform::String ^ value) = SetText;
void SetText(winrt::hstring const& value);
public void SetText(string value);
function setText(value)
Public Sub SetText (value As String)

Parameters

value
String

Platform::String

winrt::hstring

The text.

Examples

//To see this code in action, add a call to ShareSourceLoad 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!");
}

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.

Applies to