private void Menu_ItemTapped(object sender, ItemTappedEventArgs e) { MasterMenuItem item = (MasterMenuItem)e.Item; if (item.Title == current) { if (item.Title == "Home") { //_tabbedNavigationPage.SwitchSelectedRootPageModel<DailyTextPageModel>(); } ((NavigationPage)Detail).PopToRootAsync(); IsPresented = false; } current = item.Title; }
protected void CreateMenuItems() { //TopItems.Add(new MasterMenuItem //{ // Title = App.GetLanguageValue("Home", "首页"), // IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_home.png"), // Page = PageItem.Home //}); TopItems.Add(new MasterMenuItem { Title = App.GetLanguageValue("Bible", "圣经"), IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_bible.png"), Page = PageItem.Bible }); TopItems.Add(new MasterMenuItem { Title = App.GetLanguageValue("“Sing Out Joyfully”", "高声欢唱"), IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_songbook.png"), Page = PageItem.SongBook }); TopItems.Add(new MasterMenuItem { Title = App.GetLanguageValue("Publications", "出版物"), IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_publications.png"), Page = PageItem.Publications }); TopItems.Add(new MasterMenuItem { Title = App.GetLanguageValue("Dictionary", "字典"), IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_dictionary.png"), Page = PageItem.Dictionary }); //TopItems.Add(new MasterMenuItem //{ // Title = "Media", // IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_media.png"), //}); //TopItems.Add(new MasterMenuItem //{ // Title = "Meetings", // IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_meetings.png"), //}); var settings = new MasterMenuItem { Title = App.GetLanguageValue("Settings", "设置"), IconSource = String.Format("{0}{1}", Device.OnPlatform("", "", "Assets/"), "nav_settings.png"), Page = PageItem.Settings }; if (Device.RuntimePlatform == Device.Windows) { BottomItems.Add(settings); } else { BottomItems.Add(settings); } MenuTop.ItemsSource = TopItems; MenuBottom.ItemsSource = BottomItems; if (Device.RuntimePlatform == Device.Windows) { MenuTop.Header = null; MenuTop.HeightRequest = (TopItems.Count() * 48); MenuBottom.HeightRequest = (BottomItems.Count() * 48) + 1; } else { MenuTop.HeightRequest = ((TopItems.Count() + 1) * 60) + 200; MenuTop.SeparatorVisibility = SeparatorVisibility.None; MenuBottom.HeightRequest = (BottomItems.Count() * 60) + 1 + 1; //MenuBottom.HeightRequest = 1; } //if (Device.RuntimePlatform == Device.Android) //{ // var _menuPage = new ContentPage(); // _menuPage.Title = "FreshMvvmSampleApp"; // _menuPage.Content = SplitViewPane; // Master = new NavigationPage(_menuPage) { Title = "FreshMvvmSampleApp" }; //} //else //{ //} #if __ANDROID__ #endif #if __ANDROID__ #endif }
private void Menu_ItemSelected(object sender, SelectedItemChangedEventArgs e) { MasterMenuItem item = (MasterMenuItem)e.SelectedItem; if (item == null) { IsPresented = false; return; } if ((sender as ListView) == MenuTop) { MenuBottom.SelectedItem = null; } else if ((sender as ListView) == MenuBottom) { MenuTop.SelectedItem = null; } switch (item.Page) { case PageItem.Home: Detail = _tabbedNavigationPage; //Detail = _homePage; break; case PageItem.Bible: Detail = _biblePage; break; case PageItem.Publications: Detail = _publicationsPage; break; case PageItem.Dictionary: Detail = _dictionaryPage; break; case PageItem.SongBook: Detail = _tabbedNavigationPage; break; case PageItem.Settings: Detail = _settingsPage; break; default: break; } Detail.Title = item.Title; IsPresented = false; SelectedItem = item; if (Device.RuntimePlatform == Device.iOS) { ((NavigationPage)Detail).BarTextColor = Color.White; } if (Device.RuntimePlatform == Device.Android) { (sender as ListView).SelectedItem = null; } }