Source/Xamarin/Prism.DryIoc.Forms/DryIocExtensions.cs
/// <summary>
/// Registers a Page for navigation based on the Device Idiom using a shared ViewModel
/// </summary>
/// <typeparam name="TView">Default View Type to be used across multiple Idioms if they are not specified directly.</typeparam>
/// <typeparam name="TViewModel">The shared ViewModel</typeparam>
/// <param name="container"><see cref="IContainer"/> used to register type for Navigation.</param>
/// <param name="name">The common name used for Navigation. If left empty or null will default to the ViewModel root name. i.e. MyPageViewModel => MyPage</param>
/// <param name="desktopView">Desktop Specific View Type</param>
/// <param name="tabletView">Tablet Specific View Type</param>
/// <param name="phoneView">Phone Specific View Type</param>
Registers a Page for navigation based on the Device Idiom using a shared ViewModel
Registers a Page for navigation based on the Device Idiom using a shared ViewModel
public static void RegisterTypeForNavigationOnIdiom<TView, TViewModel>(this IContainer container, string name = null, Type desktopView = null, Type tabletView = null, Type phoneView = null)
            where TView : Page
            where TViewModel : class
        {
            if (string.IsNullOrWhiteSpace(name))
                name = typeof(TView).Name;
            if (Device.Idiom == TargetIdiom.Desktop && desktopView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(desktopView, name);
            }
            else if (Device.Idiom == TargetIdiom.Phone && phoneView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(phoneView, name);
            }
            else if (Device.Idiom == TargetIdiom.Tablet && tabletView != null)
            {
                container.RegisterTypeForNavigationWithViewModel<TViewModel>(tabletView, name);
            }
            else
            {
                container.RegisterTypeForNavigation<TView, TViewModel>(name);
            }
        }
public static void RegisterTypeForNavigationOnIdiom < TView , TViewModel > ( this IContainer container , string name = null , Type desktopView = null , Type tabletView = null , Type phoneView = null ) where TView : Page where TViewModel : class { if ( string . IsNullOrWhiteSpace ( name ) ) name = typeof ( TView ) . Name ; if ( Device . Idiom == TargetIdiom . Desktop && desktopView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( desktopView , name ) ; } else if ( Device . Idiom == TargetIdiom . Phone && phoneView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( phoneView , name ) ; } else if ( Device . Idiom == TargetIdiom . Tablet && tabletView != null ) { container . RegisterTypeForNavigationWithViewModel < TViewModel > ( tabletView , name ) ; } else { container . RegisterTypeForNavigation < TView , TViewModel > ( name ) ; } }
Registers a Page for navigation based on the Device Idiom using a shared ViewModel
Registers a Page for navigation based on the Device Idiom using a shared ViewModel
IContainer
this
name
string
The common name used for Navigation. If left empty or null will default to the ViewModel root name. i.e. MyPageViewModel => MyPage
The common name used for Navigation . If left empty or null will default to the ViewModel root name . i . e . MyPageViewModel = > MyPage
desktopView
Type
Desktop Specific View Type
Desktop Specific View Type
tabletView
Type
Tablet Specific View Type
Tablet Specific View Type
phoneView
Type
Phone Specific View Type
Phone Specific View Type
container
used to register type for Navigation.
used to register type for Navigation .
typeparam
Default View Type to be used across multiple Idioms if they are not specified directly.
Default View Type to be used across multiple Idioms if they are not specified directly .
typeparam
The shared ViewModel
The shared ViewModel