UWP中的协议激活
我正在开发一个UWP测试应用程序,其中需要添加协议激活。 激活逻辑写在类库中,然后作为参考添加到UWP测试应用程序中。 问题是,如果我在测试应用程序的OnActivated事件中写入逻辑,它可以正常工作,但是当在类库中的函数中写入相同的逻辑,并且从App.xaml.cs OnActivated事件调用此函数时,就会在无休止的循环中调用此OnActivated事件UWP中的协议激活,uwp,Uwp,我正在开发一个UWP测试应用程序,其中需要添加协议激活。 激活逻辑写在类库中,然后作为参考添加到UWP测试应用程序中。 问题是,如果我在测试应用程序的OnActivated事件中写入逻辑,它可以正常工作,但是当在类库中的函数中写入相同的逻辑,并且从App.xaml.cs OnActivated事件调用此函数时,就会在无休止的循环中调用此OnActivated事件 是否需要在激活的事件中创建新帧 调用OnActivated时,必须检查它是否已初始化(因为未调用OnLaunched)-创建帧并激活窗
是否需要在激活的事件中创建新帧 调用OnActivated时,必须检查它是否已初始化(因为未调用
OnLaunched
)-创建帧并激活窗口(如果未初始化)。通常可以在OnLaunched
和OnActivated
事件之间共享此初始化代码
protected override void OnActivated(IActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content
if (rootFrame == null)
{
// Create a Frame to act as the navigation context
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
//
// Handle protocol activation here
//
// Ensure the current window is active
Window.Current.Activate();
}
调用OnActivated时,必须检查它是否已初始化(因为未调用
OnLaunched
)-创建帧并激活窗口(如果未初始化)。通常可以在OnLaunched
和OnActivated
事件之间共享此初始化代码
protected override void OnActivated(IActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content
if (rootFrame == null)
{
// Create a Frame to act as the navigation context
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
//
// Handle protocol activation here
//
// Ensure the current window is active
Window.Current.Activate();
}