【发布时间】:2018-11-27 17:03:36
【问题描述】:
我已按照in the documentation 的说明进行操作;但是,当我使用指定的协议my-protocol://(在网络浏览器中输入)启动我的应用程序时,应用程序将启动,但它只是停留在启动屏幕上,就好像导航无法执行任何操作一样:
代码示例:
// MyApp.UWP/App.xaml.cs
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs =
args as ProtocolActivatedEventArgs;
// TODO: Decide where to navigate, but for now just go to main page
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(MainPage), args);
}
}
有什么明显的我做错了吗?也许有更好的方法来处理导航?还是我忽略了什么?
编辑
这特别难以排除故障,因为我不能只在 Visual Studio 中进行调试。为了测试它,我实际上必须从未连接到调试器的my-protocol:// 启动它。
从 url / 协议启动时有没有办法调试这个?
【问题讨论】:
-
在这种情况下
Window.Current.Content是否为空? -
它对我来说不是空的,但这是一件好事。
标签: xamarin.forms uwp url-scheme uwp-navigation