public RootPage() { MainTabView = new TabView(); DailyView = new DailyView(); ArticleView = new ArticleView(); CollectionView = new CollectionView(); AndroidToolBarBinder.SetMiddleText(this, TabBarText[index]); Children = new List <TabViewChildren>() { new TabViewChildren() { Text = TabBarText[0], UnSelectTextColor = Color.Gray, UnSelectImageSource = "daily_24dp.png", SelectedImageSource = "daily_24dp.png", SelectedTextColor = TabBarColorFilter, UnSelectImageColorFilter = Color.Gray, SelectedImageColorFilter = TabBarColorFilter, View = DailyView, }, new TabViewChildren() { Text = TabBarText[1], UnSelectTextColor = Color.Gray, UnSelectImageSource = "form_24dp.png", SelectedImageSource = "form_24dp.png", SelectedTextColor = TabBarColorFilter, UnSelectImageColorFilter = Color.Gray, SelectedImageColorFilter = TabBarColorFilter, View = ArticleView, }, new TabViewChildren() { Text = TabBarText[2], UnSelectTextColor = Color.Gray, UnSelectImageSource = "collection_24dp.png", SelectedImageSource = "collection_24dp.png", SelectedTextColor = TabBarColorFilter, UnSelectImageColorFilter = Color.Gray, SelectedImageColorFilter = TabBarColorFilter, View = CollectionView, }, }; MainTabView.AddChildrenViews(Children); MainTabView.SelectedChanged += Handle_SelectedChanged; Content = MainTabView; }
async void Handle_SelectedChanged(object sender, TabViewChangedEventArgs e) { index = e.Index; AndroidToolBarBinder.SetMiddleText(this, TabBarText[index]); if (index == 2) { var toolBar = new ToolbarItem() { Text = "清空" }; toolBar.Clicked += ToolBar_Clicked; this.ToolbarItems.Add(toolBar); await CollectionView.ViewModel.Refresh(); } else { if (this.ToolbarItems.Count == 0) { return; } this.ToolbarItems[0].Clicked -= ToolBar_Clicked; this.ToolbarItems.Clear(); } }
public SecondPage() { InitializeComponent(); this.BindingContext = new SecondViewModel(); AndroidToolBarBinder.SetMiddleText(this, "Second Page"); }