UWP check the current page for name or instance

社会主义新天地 提交于 2019-12-06 04:29:16

问题


In my UWP app I am launching from protocol or toast. In the onactivated method I want to check whether the apps' mainview is open or which page it is showing. All from the App.xaml.cs

I wanna do something like:

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

or

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

not sure how to go about it.


回答1:


So I'm checking for

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
}


来源:https://stackoverflow.com/questions/37503078/uwp-check-the-current-page-for-name-or-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!