UWP 检查当前页面的名称或实例 [英] UWP check the current page for name or instance
本文介绍了UWP 检查当前页面的名称或实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 UWP 应用中,我从协议或 Toast 启动.在 onactivated 方法中,我想检查应用程序的主视图是否打开或显示的是哪个页面.全部来自 App.xaml.cs
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
我想做类似的事情:
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
}
这篇关于UWP 检查当前页面的名称或实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文