Compartilhar via


HtmlFormatHelper.CreateHtmlFormat(String) Método

Definição

Usa uma cadeia de caracteres que representa o conteúdo HTML e adiciona os cabeçalhos necessários para garantir que ele seja formatado corretamente para operações de compartilhamento e área de transferência.

public:
 static Platform::String ^ CreateHtmlFormat(Platform::String ^ htmlFragment);
 static winrt::hstring CreateHtmlFormat(winrt::hstring const& htmlFragment);
public static string CreateHtmlFormat(string htmlFragment);
function createHtmlFormat(htmlFragment)
Public Shared Function CreateHtmlFormat (htmlFragment As String) As String

Parâmetros

htmlFragment
String

Platform::String

winrt::hstring

Uma cadeia de caracteres que representa o conteúdo HTML.

Retornos

String

Platform::String

winrt::hstring

Uma cadeia de caracteres que representa o HTML formatado.

Exemplos

public void ShareSourceLoad()
{
    DataTransferManager dataTransferManager = DataTransferManager.GetForCurrentView();
    dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.DataRequested);
}

async void DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
    string htmlExample = "<p>Here is our store logo: <img src='assets/logo.png'>.</p>";
    string fileExample = "assets\\logo.png";
    RandomAccessStreamReference streamRef = null;
    Windows.Storage.StorageFile file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileExample);
    try
    {
        streamRef = Windows.Storage.Streams.RandomAccessStreamReference.CreateFromFile(file);
    }
    catch (Exception ex)
    {
        // TODO: Handle the exception.
    }
    string htmlFormat = Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.CreateHtmlFormat(htmlExample);
    DataRequest request = e.Request;
    request.Data.Properties.Title = "Share HTML Example";
    request.Data.Properties.Description = "An example of how to share HTML.";
    request.Data.SetHtmlFormat(htmlFormat);
    request.Data.ResourceMap[fileExample] = streamRef;
}

Aplica-se a