Hi @BitSmithy ,
Welcome to Microsoft Q&A!
OnActivated(IActivatedEventArgs args) event isnt implemented in opened app because I do nothing when I open the app, I want simplu opent it.
I think this is the reason for the unexpected behavior, you did nothing in OnActivated.
Refer to the official sample Association launching sample and you should initialize the root Frame and activate the Window.
You can try adding this code in the opened app(App.xaml.cs). I tested it and it works
protected override void OnActivated(IActivatedEventArgs e)
{
if (e.Kind == ActivationKind.Protocol)
{
Frame rootFrame = CreateRootFrame();
if (rootFrame.Content == null)
{
if (!rootFrame.Navigate(typeof(MainPage)))
{
throw new Exception("Failed to create initial page");
}
}
rootFrame.Navigate(typeof(MainPage), e);
// Ensure the current window is active
Window.Current.Activate();
}
}
private Frame CreateRootFrame()
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
// Set the default language
rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
rootFrame.NavigationFailed += OnNavigationFailed;
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
return rootFrame;
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.