Sharing target Universal Apps Windows 10 approach

纵然是瞬间 提交于 2019-12-05 18:22:57

I'm pasting the solution which solved the issue. I think the key here is to use

CoreWindow.GetForCurrentThread().Dispatcher

 protected override async void OnShareTargetActivated(ShareTargetActivatedEventArgs args)
        {
            await OnInitializeAsync();

            if (await CheckToken(args) != true) return;

            if (args.PreviousExecutionState != ApplicationExecutionState.Running)
            {
                if (await LoadData(args) != true) return;
            }

            var frame = new Frame();
            Window.Current.Content = frame;
            var dispatchService = new DispatcherService() { Dispatcher = CoreWindow.GetForCurrentThread().Dispatcher };
            var navigationService = new NavigationService(dispatchService) { RootFrame = frame };
            navigationService.Navigate<ShareViewModel>(args.ShareOperation);
            Window.Current.Activate();
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!