I have a page in my application which share simple text, not working properly.
Steps to produce this functionality.
Go to Page click share it shows application which can share.
Tap back button => click again on share button.
This will not open share screen this time.
Pasting my code below:
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
_dataTransferManager.DataRequested -= OnDataRequested;
this.navigationHelper.OnNavigatedFrom(e);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
_dataTransferManager = DataTransferManager.GetForCurrentView();
_dataTransferManager.DataRequested += OnDataRequested;
this.navigationHelper.OnNavigatedTo(e);
}
private void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
e.Request.Data.Properties.Title = obj.Title;
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(obj.Description);
string html = "";
foreach (HtmlNode item in doc.DocumentNode.Descendants())
{
if (item.Name == "body")
{
html = item.InnerHtml;
}
}
e.Request.Data.Properties.Description = html;
e.Request.Data.SetText(html);
}
private void AppBarButton_Click_1(object sender, RoutedEventArgs e)
{
//DataTransferManager.ShowShareUI();
if (CMSService.IsConnectedToInternet())
{
DataTransferManager.ShowShareUI();
}
else
{
ContentText.Text = App.GetResource("NoInternetAlert");
AlertMessage.ShowAsync();
}
}
And while debugging share works all the time.