通过文件类型关联打开Xamarin UWP应用后,打开开始页面

时间:2018-11-01 13:39:52

标签: xamarin uwp xamarin.uwp file-type-associations

我已经注册了文件类型关联以打开我的自定义文件格式.xoip。当我打开.xoip文件时,App类中的OnFileActivated函数被启动,但是没有创建MainPage。

根据文件的联系方式,我想在OnFileActivated函数中决定是否启动我的起始页。我必须打什么电话才能开始起始页?

1 个答案:

答案 0 :(得分:1)

使用文件类型关联,您需要手动指定打开特定文件时要加载的页面。

激活任何关联的文件后,它将调用App.xaml.cs的OnFileActivated。 您可以使用该方法添加逻辑以导航到特定页面。请参考以下代码:

protected override void OnFileActivated(FileActivatedEventArgs args)
{
   base.OnFileActivated(args);
   var rootFrame = new Frame();
   rootFrame.Navigate(typeof(MainPage), args);
   Window.Current.Content = rootFrame;
   Window.Current.Activate();
}
相关问题