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

时间:2016-05-28 19:33:09

标签: c# windows windows-runtime win-universal-app uwp

在我的UWP应用程序中,我正在从协议或吐司中启动。在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.

不确定如何去做。

1 个答案:

答案 0 :(得分:9)

所以我正在检查

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
}