【问题标题】:Opening the start page after opening Xamarin UWP app via File Type Associations通过文件类型关联打开 Xamarin UWP 应用后打开起始页
【发布时间】:2019-04-05 17:57:31
【问题描述】:

我已经注册了一个文件类型关联来打开我的自定义文件格式.xoip。当我打开 .xoip 文件时,App 类中的 OnFileActivated-function 会启动,但不会创建 MainPage。

根据文件的联系方式,我想在OnFileActivated-function 中决定是否启动我的起始页。我必须调用什么来启动起始页?

【问题讨论】:

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


    【解决方案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();
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-18
      • 2020-08-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-31
      相关资源
      最近更新 更多