Page being loaded twice when App being launched through protocol activation
Hello all,
I'm working on a application that is being called upon by our company's other apps. This is done through protocol activation.
In the OnStartAsync method we check if the app is being started by Protocol Activation Kind and what kind of workorderId is being send with the protocol call. Next we navigate to the mainpage with the workorderid.
In the OnNavigatedTo on the MainPage I get the worderorderId and can load the data.
This is all working like it should, the problem is when the OnNavigatedTo method is all done; The app tries to navigate to the current(mainpage) again, without my code anywhere calling a Navigate to mainpage...
At the moment I temporarily solved this by cancelling the navigation event in the OnNavigatedFrom method.
- Tried this with a different Template10 project and I got the same result, the first page being loaded twice..
- Also tried to protocol launch a none Template10 project and the first page is not being loaded twice, just how it should.
Anyone got any ideas?
Couldn't even wager a guess without some source to see from app.xml.cs and your main page nav events
App.xaml.cs >
public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
var protocolResultArgs = args as ProtocolActivatedEventArgs;
Uri uri = protocolResultArgs.Uri;
NavigationService.Navigate(typeof(Views.MainPage), uri);
}
else
{
NavigationService.Navigate(typeof(Views.MainPage));
}
await Task.CompletedTask;
And mainpage.
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> suspensionState)
{
if (parameter != null)
{
var uri = parameter as Uri;
Uri = uri;
}
await Task.CompletedTask;
}
This is my test project with the same result as my main project, very basic stuff.
Please investigate StartKind
I rewrote my code, and it seems to be working now. I was to fast with asking for help here I guess ;) But thanks anyway!