Use a Simplest Route to Develop a Master Detail Page Navigation Menu in Xamarin Forms with Prism

xamarin_master_detail_page_tutorial

At the time of the development of a multi-pages website or mobile application, the page navigation feature is its must requirement. If you are developing an app under the Xamarin technology with the Xamarin.Forms then you  have to be thankful to its prism library. The individuals who are still not know the facts and features of Prism have to become familar with it first that Prism is a XAML application framework with having some in-built key features like:

  • MVVM Supportive
  • Commanding
  • Messaging
  • Logging
  • Navigation and more.

Now coming back to the main topic of our this blog post as how can we create a page navigation menu in the Xamarin.Forms with the Prism. So, to go forward this, at first you need to create a new project, with this you also need some nudget packages to getting started working with prism.

Now create three different folders in your project as with the name od Models, Views, and ViewMoels, before to install the nudget package. In this chapter you need to install three pagkages in it which are as:

  1. Core
  2. Forms
  3. SOME_IOC_CONTRAINER.Forms

Now start the installation process of these nudgets in your project by hitting the right click of your mouse on the solution. After the successful installation, edit some code lines in the file App.xaml and App.cs

Do the following code changes in App.xaml file:

<prism:PrismApplication xmlns=”http://xamarin.com/schemas/2014/forms”
             xmlns:x=”http://schemas.microsoft.com/winfx/2009/xaml”
             xmlns:prism=”clr-namespace:Prism.Autofac;assembly=Prism.Autofac.Forms”
             x:Class=”XF.MasterDetailPage.Prism.App”>
                <Application.Resources>
                                <!– Application resource dictionary –>
                </Application.Resources>
</prism:PrismApplication>

Do the following code changes in App.cs file:

using Prism.Autofac;
using Prism.Ioc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
using XF.MasterDetailPage.Prism.Views;
namespace XF.MasterDetailPage.Prism {
    public partial class App : PrismApplication {
        public App(IPlatformInitializer initializer = null) : base(initializer) {
            InitializeComponent();
        }
        protected override void OnInitialized() {
        }
        protected override void RegisterTypes(IContainerRegistry containerRegistry) {
 
        }
        protected override void OnStart() {
            // Handle when your app starts
        }
        protected override void OnSleep() {
            // Handle when your app sleeps
        }
        protected override void OnResume() {
            // Handle when your app resumes
        }
    }
}

Simply here we can see two new methods as RegisterTypes and OnInitialized. From which here we are using registertype method for registering the navigationin the app.

Create a new masterDetail page in your project’s View with ViewModel, by the use of prism libraby which is called ViewModelLocator.AutowireViewModel. You need to add this namespaces in this file like:

<MasterDetailPage xmlns=”http://xamarin.com/schemas/2014/forms”
             xmlns:x=”http://schemas.microsoft.com/winfx/2009/xaml”
             x:Class=”XF.MasterDetailPage.Prism.Views.MenuPage”
             xmlns:prism=”clr-namespace:Prism.Mvvm;assembly=Prism.Forms”
             prism:ViewModelLocator.AutowireViewModel=”True” >
</MasterDetailPage>

Read More – Hire xamarin DeveloperXamarin Development Company

 

 

 

by admin

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>