WinUI get Launched Param, args.UWPLaunchActivatedEventArgs.Kind is aways returning as 'launch'

 

想尝鲜WinUI, 整了个小小的WinUI桌面程序。

想要获取关联文件,通过文件的打开方式启动我的软件,一直取不到启动参数。纠结了一整天,难受死了。尝鲜WinUI的痛苦。

最后用Appinstance的GetActivatedEventArgs().Kind取到想要的参数。

 protected  override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
        {
            //args.UWPLaunchActivatedEventArgs.Kind  //Not this Kind
            Microsoft.Windows.AppLifecycle.AppInstance appInstance =
            Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent();
            var kind = appInstance.GetActivatedEventArgs().Kind;
}

 

posted @ 2022-01-23 06:25  陈夏松  阅读(36)  评论(0编辑  收藏  举报