共用方式為


StandardDataFormats.Html 屬性

定義

唯讀屬性,會傳回對應至 HTML 格式的格式識別碼字串值。

public:
 static property Platform::String ^ Html { Platform::String ^ get(); };
static winrt::hstring Html();
public static string Html { get; }
var string = StandardDataFormats.html;
Public Shared ReadOnly Property Html As String

屬性值

String

Platform::String

winrt::hstring

對應至 HTML 格式的格式識別碼字串值。

範例

此範例示範 Html 屬性的使用。 若要使用此範例中的程式碼,請將事件接聽程式新增至您的應用程式以處理 啟動 的事件。 然後將此程式碼放入這個事件接聽程式所呼叫的函式中。

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;
}

適用於