Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP check the current page for name or instance

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.

like image 230
SunnySonic Avatar asked May 28 '16 19:05

SunnySonic


1 Answers

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
}
like image 51
SunnySonic Avatar answered Nov 04 '22 22:11

SunnySonic