gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 13:28:31 24 4
gpt4 key购买 nike

在我的 UWP 应用程序中,我从协议(protocol)或 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
}

关于c# - UWP 检查当前页面的名称或实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37503078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com