0
在windows phone 8中,我们使用ShareStatusTask
共享状态。因为Microsoft.Ppone.Task
在Windows Phone 8.1中不可用,所以我们如何在Windows Phone 8.1通用应用程序中共享状态?什么相当于这个功能?如何在windows phone 8.1通用应用程序中使用共享状态
在windows phone 8中,我们使用ShareStatusTask
共享状态。因为Microsoft.Ppone.Task
在Windows Phone 8.1中不可用,所以我们如何在Windows Phone 8.1通用应用程序中共享状态?什么相当于这个功能?如何在windows phone 8.1通用应用程序中使用共享状态
新的共享方式就像Windows商店应用程序中的共享方式。 Windows可以询问程序是否有任何可共享的内容,以及可能的内容。为此,您需要在视图中实现一个可以在DataTransferManager中共享和设置的函数。完善的代码可能看起来像:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
// Register the current page as a share source.
_dataTransferManager = DataTransferManager.GetForCurrentView();
_dataTransferManager.DataRequested += OnDataRequested;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
// Unregister the current page as a share source.
_dataTransferManager.DataRequested -= OnDataRequested;
}
protected void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
e.Request.Data.Properties.Title = "Some title";
e.Request.Data.Properties.Description = "Some description"; // Optional
e.Request.Data.SetUri(new Uri("http://www.some_uri.com"));
}