UWP 检查当前页面的名称或实例

UWP check the current page for name or instance

在我的 UWP 应用程序中,我从协议或 toast 启动。在 onactivated 方法中,我想检查应用程序的主视图是否打开或它显示的是哪个页面。全部来自App.xaml.cs

我想做类似的事情:

If Mainpage is not showing --> Navigate(typeof(MainPage));

If main window is not open since i am coming from protocol or toast launch
open frame and navigate to mainpage.

不知道该怎么做。

所以我正在检查

var frame = Window.Current.Content as Frame;

if (frame != null)
{
    Type whatpageisit = frame.SourcePageType;
    // handle this page type
}
else
{
    // do what you need to in case window not open
}