protected override void OnLaunched(LaunchActivatedEventArgs e) { // Handle launch activation event Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Window.Current.Activate(); } }
protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); if (args.Kind == ActivationKind.Protocol) { // Handle protocol activation event ProtocolActivatedEventArgs protocolArgs = args as ProtocolActivatedEventArgs; if (protocolArgs != null) { Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); } rootFrame.Navigate(typeof(MainPage), protocolArgs.Uri.AbsoluteUri); Window.Current.Content = rootFrame; Window.Current.Activate(); } } }In this example, OnActivated event is handled when the application is activated via Protocol activation kind. It retrieves the protocol information from ProtocolActivatedEventArgs and navigates to the Main Page of the application. Package Library: Windows.ApplicationModel.Activation Both examples are using different package libraries as they are handling different application activation events.