![](/img/trans.png)
[英]Getting an exception as “A method was called at an unexpected time” when using share contract for sharing files in windows 8 metro app?
[英]Is it possible to set a subject to the mail app in Windows 8 metro application, if I am using share contract and sharing files?
首先,我将我的Windows 8 metro应用程序中的内容共享到另一个应用程序(例如Mailto应用程序),所以:
现在我使用共享合同和我的应用程序共享文件共享文件到mailto应用程序,
我想知道是否: -
我可以将主题设置为我共享文件的mailto应用程序作为该mailto应用程序的附件,如果是这样,请让我知道我该怎么做?
如果没有,请让我知道这是什么工作?
截至目前,这是不可能的。
Windows 8最近推出了一种名为协议激活的新API。 通过协议激活,您可以从应用程序启动其他Windows 8应用程序并传入数据。 Microsoft在Maps应用程序上工作,您现在可以将信息传递到Map应用程序,如此处所示(地图应用程序的URI方案) http://msdn.microsoft.com/en-us/library/windows/apps/jj635237.aspx
请参阅http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html上的代码演练。
现在,我很快就会确定,您将看到一些可以使用协议激活从您的应用程序传递的Mail应用程序的自定义参数。
只需2美分
不,目前无法做到这一点。
我可能没有正确理解这个问题,但如果你想要做的就是能够点击Charms栏上的“分享”按钮,那么选择“邮件”应用程序并能够填充当前显示的主题行。显示“邮件”应用程序的共享弹出,然后您可以按照以下方法操作:
private DataTransferManager dataTransferManager; //class member
// put the following code block wherever you need it:
// Register as a share source
if (this.dataTransferManager == null)
{
this.dataTransferManager = DataTransferManager.GetForCurrentView();
this.dataTransferManager.DataRequested -= this.OnDataRequested;
try
{
this.dataTransferManager.DataRequested += new TypedEventHandler<DataTransferManager, DataRequestedEventArgs>(this.OnDataRequested);
}
catch
{
};
}
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
DataRequest request = e.Request;
DataRequestDeferral deferal = request.GetDeferral();
try
{
// this property will set your subject line
// it will also be shown on the Share fly-out (right below the main
// heading that says 'Share'
request.Data.Properties.Title = GetCustomMailSubjectLine();
if (string.IsNullOrEmpty(request.Data.Properties.Title))
{
request.FailWithDisplayText("An operation failed. Please try again.");
}
else
{
// this will also be shown on the Share fly-out, right below the 'Title'
// property set above
request.Data.Properties.Description = GetMyAppsSharingDesciption();
// use request.Data.SetDataProvider() if your data needs to be asynchronously retrieved
// otherwise directly use request.Data.SetData() (or one of the other
//methods depending on what you need)
request.Data.SetDataProvider(StandardDataFormats.Html, RetrieveSharedData);
}
}
finally
{
deferal.Complete();
}
}
private async void RetrieveSharedData(DataProviderRequest request)
{
DataProviderDeferral deferal = request.GetDeferral();
try
{
// this will set your email's body
request.SetData(await GetCustomMailBodyAsync());
}
finally
{
deferal.Complete();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.