Example #1
0
        //Former constructor.

        /*public App ()
         * {
         *      InitializeComponent();
         *
         * MainPage = new NavigationPage(new MainPage());
         * }*/

        /// <summary>
        /// Initializes a new instance of the App Class
        /// </summary>
        /// <param name="path"></param>
        public App(string path)
        {
            InitializeComponent();

            //Gets the database path send from BooksMVVM.Android.MainActivity.cs
            DB_PATH = path;

            //Instansiates the different viewmodels and pages.
            MainDAL dal = new MainDAL();
            IAddProductPageViewModel addProductPageViewModel = new AddProductPageViewModel(dal);
            AddProductPage           addproductPage          = new AddProductPage(addProductPageViewModel);
            IMakeListPageViewModel   makeListPageViewModel   = new MakeListPageViewModel(dal);
            MakeListPage             makeListPage            = new MakeListPage(makeListPageViewModel);
            //Not sure if this violates MVVM, but it needs them to navigate between pages.
            //One way to fix this could maybe be to simple have to codebehind handle the navigation
            //but I am not sure if it violates MVVM.
            IMainPageViewModel mainPageViewModel = new MainPageViewModel(addproductPage, makeListPage, dal);
            MainPage           mainPage          = new MainPage(mainPageViewModel);
            NavigationPage     navigationPage    = new NavigationPage(mainPage)
            {
                BarBackgroundColor = Color.FromHex("#2199e8"),
                BarTextColor       = Color.White
            };

            MainPage = navigationPage;
        }
Example #2
0
        public AddProductPage()
        {
            this.InitializeComponent();
            var vm = new AddProductPageViewModel(new NavigationService());

            this.DataContext = vm;
        }
        public AddProductPage()
        {
            InitializeComponent();

            BindingContext = _ViewModel = new AddProductPageViewModel();

            MessagingCenter.Subscribe <AddProductPageViewModel>(this, "NoDataAlert", async(sender) =>
            {
                await DisplayAlert("Enter Data Alert", "Please enter data", "Ok");
            });

            MessagingCenter.Subscribe <AddProductPageViewModel>(this, "Success", async(sender) =>
            {
                await DisplayAlert("Success", "Success", "Ok");

                await Navigation.PopAsync();
            });
        }
Example #4
0
 private async void Init()
 {
     InitializeComponent();
     this.BindingContext       = viewModel = new AddProductPageViewModel();
     viewModel.AddProductModel = new AddProductModel();
 }