Inheritance: BaseViewModel
Ejemplo n.º 1
0
        public HomeMasterView(HomeViewModel viewModel)
        {
            Icon = "slideout.png";
            BindingContext = viewModel;
            
			var layout = new BaseStackLayout 
			{ 

				BackgroundColor = Color.DarkGray.ToFormsColor(),
				Spacing = 0,
				Padding = new Thickness(0)
			};

            #region Add list view to layout

			var cell = new DataTemplate(typeof(ListImageCell));
			cell.SetBinding(TextCell.TextProperty, "Title");
			cell.SetBinding(ImageCell.ImageSourceProperty, "Icon");

            ListView = new ListView
			{
				BackgroundColor = Color.DarkGray.ToFormsColor(),
				ItemTemplate = cell,
				ItemsSource = viewModel.MenuItems
			};

            // Set default selected item to settings view
            if (_postsListView == null)
                _postsListView = new PostsListView();

            PageSelection = _postsListView;

            //Change to the correct page
            ListView.ItemSelected += ListItemSelected;
			ListView.SelectedItem = viewModel.MenuItems.FirstOrDefault(a => a.MenuType == HomeMenuType.Posts);
            layout.Children.Add(ListView);
            
            #endregion

            Content = layout;
        }
Ejemplo n.º 2
0
        public HomeView()
        {
            _pages = new Dictionary<HomeMenuType, NavigationPage>();
            BindingContext = new HomeViewModel();

            Master = _master = new HomeMasterView(ViewModel);

			var homeNav = new BaseNavigationPage (_master.PageSelection);
            Detail = homeNav;

            _pages.Add(HomeMenuType.Posts, homeNav);

            _master.PageSelectionChanged = async menuType =>
            {
                if (Detail != null && Device.OS == TargetPlatform.WinPhone)
                {
                    await Detail.Navigation.PopToRootAsync();
                }

                NavigationPage newPage;

                if (_pages.ContainsKey(menuType))
                {
                    newPage = _pages[menuType];
                }
                else
                {
					newPage = new BaseNavigationPage (_master.PageSelection);
                    _pages.Add(menuType, newPage);
                }
                Detail = newPage;
                Detail.Title = _master.PageSelection.Title;
                IsPresented = false;
            };

            Icon = "slideout.png";
			//IsLoggedIn ();
        }