当前位置: 首页>>代码示例>>C#>>正文


C# NavigationMode.ToPrismNavigationMode方法代码示例

本文整理汇总了C#中NavigationMode.ToPrismNavigationMode方法的典型用法代码示例。如果您正苦于以下问题:C# NavigationMode.ToPrismNavigationMode方法的具体用法?C# NavigationMode.ToPrismNavigationMode怎么用?C# NavigationMode.ToPrismNavigationMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NavigationMode的用法示例。


在下文中一共展示了NavigationMode.ToPrismNavigationMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NavedToAsync

        public async Task NavedToAsync(object viewmodel, NavigationMode mode, Page sourcePage, Type sourceType, object sourceParameter, Page targetPage, Type targetType, object targetParameter)
        {
            Services.NavigationService.NavigationService.DebugWrite();

            if (targetPage == null)
            {
                throw new ArgumentNullException(nameof(targetPage));
            }

            if (mode == NavigationMode.New)
            {
                PageState(targetPage).Clear();
            }

            if (viewmodel == null)
            {
                return;
            }
            else if (viewmodel is Classic.INavigatedAwareAsync)
            {
                var vm = viewmodel as Classic.INavigatedAwareAsync;
                await vm?.OnNavigatedToAsync(targetParameter, mode, PageState(targetPage));
            }
            else if (viewmodel is Portable.INavigatedAware)
            {
                var parameters = new Portable.NavigationParameters();
                parameters.Add("NavigationMode", mode.ToPrismNavigationMode());
                parameters.Add("SourceType", sourceType);
                parameters.Add("SourceParameter", sourceParameter);
                parameters.Add("TargetType", targetType);
                parameters.Add("TargetParameter", targetParameter);
                var vm = viewmodel as Portable.INavigatedAware;
                vm?.OnNavigatedTo(parameters);
            }
            else if (viewmodel is Portable.INavigatedAwareAsync)
            {
                var parameters = new Portable.NavigationParameters();
                parameters.Add("NavigationMode", mode.ToPrismNavigationMode());
                parameters.Add("SourceType", sourceType);
                parameters.Add("SourceParameter", sourceParameter);
                parameters.Add("TargetType", targetType);
                parameters.Add("TargetParameter", targetParameter);
                var vm = viewmodel as Portable.INavigatedAwareAsync;
                await vm?.OnNavigatedToAsync(parameters);
            }

            targetPage.InitializeBindings();
            targetPage.UpdateBindings();
        }
开发者ID:GFlisch,项目名称:Template10,代码行数:49,代码来源:NavigationLogic.cs

示例2: NavingFromCancelsAsync

        public async Task<bool> NavingFromCancelsAsync(object viewmodel, NavigationMode mode, Page sourcePage, Type sourceType, object sourceParameter, Page targetPage, Type targetType, object targetParameter, bool suspending)
        {
            Services.NavigationService.NavigationService.DebugWrite();

            if (sourcePage == null)
            {
                return false;
            }
            else if (viewmodel == null)
            {
                return false;
            }
            else if (viewmodel is Classic.INavigatingAwareAsync)
            {
                var deferral = new DeferralManager();
                var navigatingEventArgs = new Classic.NavigatingEventArgs(deferral)
                {
                    Page = sourcePage,
                    PageType = sourcePage?.GetType(),
                    Parameter = sourceParameter,
                    NavigationMode = mode,
                    TargetPageType = targetType,
                    TargetPageParameter = targetParameter,
                    Suspending = suspending,
                };
                try
                {
                    var vm = viewmodel as Classic.INavigatingAwareAsync;
                    await vm?.OnNavigatingFromAsync(navigatingEventArgs);
                    await deferral.WaitForDeferralsAsync();
                }
                catch
                {
                    Debugger.Break();
                }
                return navigatingEventArgs.Cancel;
            }
            else if (viewmodel is Portable.IConfirmNavigationAsync)
            {
                var parameters = new Portable.NavigationParameters();
                parameters.Add("NavigationMode", mode.ToPrismNavigationMode());
                parameters.Add("SourceType", sourceType);
                parameters.Add("SourceParameter", sourceParameter);
                parameters.Add("TargetType", targetType);
                parameters.Add("TargetParameter", targetParameter);
                parameters.Add("Suspending", suspending);
                var vm = viewmodel as Portable.IConfirmNavigationAsync;
                return !await vm?.CanNavigateAsync(parameters);
            }
            else
            {
                return true;
            }
        }
开发者ID:GFlisch,项目名称:Template10,代码行数:54,代码来源:NavigationLogic.cs


注:本文中的NavigationMode.ToPrismNavigationMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。