I'm having a problem with the share target implementation in my app. It is driving me crazy.
I have in my App.xaml.cs :
protected override void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
{
var rootFrame = new Frame();
rootFrame.Navigate(typeof(ShareTarget), args.ShareOperation);
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
working fine! --> next:
In my ShareTarget.cs I would "simply" like to open the apps main window if open or not open.
Currently I have:
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => Frame.Navigate(typeof(MainPage), this));
which only opens the Mainpage on the right side inside the "sharing" frame. I would like to open the main frame.
in the OnNavigatedTo method of MainPage
Here I tried opening a new View and dismissing the sharing frame with:
var newView = CoreApplication.CreateNewView();
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
var frame = new Frame();
frame.Navigate(typeof(MainPage), null);
Window.Current.Content = frame;
});
If the app is closed i get this error:
WinRT information: Could not create a new view because the main window has not yet been created
If the app is open the sharing frame on the right navigates to MainPage and closes after a few seconds.
Can't believe Microsoft has made it so difficult to form a proper implementation.
The only way that seems to be possible is like @Raymon Chen suggested through creating a protocol launch.
I used this page to which explains it all pretty well:
http://www.c-sharpcorner.com/UploadFile/6f0898/inter-app-communications-in-windows-10-uwp535/
It contains some typos. Please be careful.