本文整理汇总了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();
}
示例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;
}
}