Documente Academic
Documente Profesional
Documente Cultură
Unity;
using Prism.Mvvm;
using Prism.Navigation;
using Prism.Unity;
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace HelloWorld
{
public static class NavigationExtensions
{
public static IUnityContainer RegisterTypeForViewModelNavigation<TView,
TViewModel>(this IUnityContainer container)
where TView : Page
where TViewModel : class
{
var viewType = typeof(TView);
ViewModelLocationProvider.Register(viewType.ToString(),
typeof(TViewModel));
return container.RegisterTypeForNavigation(viewType,
typeof(TViewModel).FullName);
}
/// <summary>
/// Initiates navigation to the target specified by the <typeparamref
name="TViewModel"/>.
/// </summary>
/// <typeparam name="TViewModel">The type which will be used to identify
the name of the navigation target.</typeparam>
/// <param name="parameters">The navigation parameters</param>
/// <param name="useModalNavigation">If <c>true</c> uses PopModalAsync, if
<c>false</c> uses PopAsync</param>
/// <param name="animated">If <c>true</c> the transition is animated, if
<c>false</c> there is no animation on transition.</param>
public static Task NavigateAsync<TViewModel>(this INavigationService
navigationService, NavigationParameters parameters = null, bool? useModalNavigation
= null, bool animated = true)
where TViewModel : BindableBase
{
return navigationService.NavigateAsync(typeof(TViewModel).FullName,
parameters, useModalNavigation, animated);
}
}
}