我有需要分享的HTML代码。当我在Windows桌面/笔记本电脑(Winrt)上运行以下代码时,它会在outlook或gmail应用程序中显示数据和图像,但是当我尝试在Windows Phone 8.1上共享时,它只显示标题但不显示html内容。< / p>
DataTransferManager manager = null;
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
manager = DataTransferManager.GetForCurrentView();
manager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(share_DataRequested);
}
private void share_DataRequested(object sender, DataRequestedEventArgs e)
{
DataRequestDeferral deferral = e.Request.GetDeferral();
DataRequest request = e.Request;
request.Data.Properties.Title = "This is my Title";
request.Data.Properties.ApplicationName = "App Name";
StringBuilder builder = new StringBuilder();
builder.Append("<img src='URI_Image' title='something' /> ");
builder.Append("<pre style='font-family:Helvetica'>some data</pre>");
request.Data.SetHtmlFormat(HtmlFormatHelper.CreateHtmlFormat(builder.ToString()));
deferral.Complete();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
DataTransferManager.ShowShareUI();
}
我该如何解决这个问题..
答案 0 :(得分:0)
尝试将您的代码更改为:
var builder = new StringBuilder();
builder.Append(@"<!DOCTYPE html>");
builder.Append(@"<html itemscope itemtype="http://schema.org/QAPage">");
builder.Append(@"<head>");
builder.Append(@"<title>My web page</title>");
builder.Append(@"</head>");
builder.Append(@"<body>");
builder.Append(@"<img src="URI_Image" title="something" /> ");
builder.Append(@"<pre style="font-family:Helvetica">some data</pre>");
builder.Append(@"</head>");
builder.Append(@"</body>");
builder.Append(@"</html>");