static IEnumerable <ElementInfo> FindInTitle(Element element, Predicate <Element> predicate, Predicate <Element> containerPredicate) { var result = new List <ElementInfo>(); IEnumerable <ElementInfo> empty = new List <ElementInfo>(); View titleView = null; if (element is Page && element.Parent is TabbedPage && TitleViewIsVisible(element.Parent)) { titleView = NavigationPage.GetTitleView(element.Parent as Page); } else if (TitleViewIsVisible(element)) { titleView = NavigationPage.GetTitleView(element as Page); } if (titleView != null) { result.AddRange(titleView.Find(predicate, containerPredicate) ?? empty); } else { result.AddRange((element as Page)?.ToolbarItems.ToList().Where(predicate.Invoke).Select(ElementInfo.FromElement) ?? empty); } return(result); }
public PopularesPage() { InitializeComponent(); _currentNavigationView = NavigationPage.GetTitleView(this); IconImageSource = ImageSource.FromResource("Pokedex.imagesTab.promocaoTabble.png"); SetPokemonPopularesList(); }
protected override void OnAppearing() { base.OnAppearing(); Load(); TitleView = NavigationPage.GetTitleView(this); ViewModel.ViewModelNavigation = TitleView.BindingContext as NavigationAnimalViewModel; }
void UpdateTitleView() { AToolbar bar = Toolbar; if (bar == null) { return; } Page currentPage = CurrentPage; if (currentPage == null) { return; } VisualElement titleView = NavigationPage.GetTitleView(currentPage); if (_titleViewHandler != null) { var reflectableType = _titleViewHandler as System.Reflection.IReflectableType; var rendererType = reflectableType != null?reflectableType.GetTypeInfo().AsType() : _titleViewHandler.GetType(); if (titleView == null || Internals.Registrar.Registered.GetHandlerTypeForObject(titleView) != rendererType) { if (_titleView != null) { _titleView.Child = null; } _titleViewHandler.VirtualView.Handler = null; _titleViewHandler = null; } } if (titleView == null) { return; } if (_titleViewHandler != null) { _titleViewHandler.SetVirtualView(titleView); } else { titleView.ToNative(MauiContext); _titleViewHandler = titleView.Handler; if (_titleView == null) { _titleView = new Container(NavigationLayout.Context); bar.AddView(_titleView); } _titleView.Child = (INativeViewHandler)_titleViewHandler; } }
static bool TitleViewIsVisible(Element element) { if (element?.FindParent <NavigationPage>() == null) { return(false); } var page = element as Page ?? new Page(); return(NavigationPage.GetTitleView(page) != null); }
public void TitleViewSetProperty() { var root = new ContentPage(); var nav = new NavigationPage(root); View target = new View(); NavigationPage.SetTitleView(root, target); var result = NavigationPage.GetTitleView(root); Assert.AreSame(result, target); }
protected override void OnAppearing() { base.OnAppearing(); var bc = (ClientsViewModel)BindingContext; if (bc != null) { if (bc.IsEditing) { (NavigationPage.GetTitleView(this) as NavTitleView).SubTitle = "Edito " + bc.SelectedClient.Name; } } }
/// <summary> /// The OnCurrentPageChanged /// </summary> /// <param name="sender">The sender<see cref="object"/></param> /// <param name="e">The e<see cref="EventArgs"/></param> private void OnCurrentPageChanged(object sender, EventArgs e) { if (CurrentPage == null) { return; } var titleView = NavigationPage.GetTitleView(CurrentPage); if (titleView != null) { NavigationPage.SetTitleView(this, titleView); } }
static void changeTitleView(Page page) { var currentView = NavigationPage.GetTitleView(page); if (currentView is Grid) { NavigationPage.SetTitleView(page, createSearchBarView()); } else if (currentView is SearchBar) { NavigationPage.SetTitleView(page, null); } else { NavigationPage.SetTitleView(page, createGrid()); } }
void changeTitleView_Clicked(object sender, EventArgs e) { var currentView = NavigationPage.GetTitleView(Navigation.NavigationStack.Last()); if (currentView is Grid) { NavigationPage.SetTitleView(Navigation.NavigationStack.Last(), createSearchBarView()); } else if (currentView is SearchBar) { NavigationPage.SetTitleView(Navigation.NavigationStack.Last(), null); } else { NavigationPage.SetTitleView(Navigation.NavigationStack.Last(), createGrid()); } }
static string GetTitle(ContentPage page) { var navigation = page?.Navigation; if (navigation == null) { return(""); // without navigation the user can't see the title } var titleView = NavigationPage.GetTitleView(page); if (titleView != null) { return($"*{RenderContent(titleView).Replace("\n", "").Replace("· ", " ").Replace(" ", "")} *"); } var title = navigation.NavigationStack.LastOrDefault()?.Title; return(title + " " + string.Join(" ", page.ToolbarItems.Select(t => $"[{t.Text}]"))); }
public NavigationBarGallery(NavigationPage rootNavPage) { _rootNavPage = rootNavPage; int toggleBarTextColor = 0; int toggleBarBackgroundColor = 0; ToolbarItems.Add(new ToolbarItem { Text = "Save" }); NavigationPage.SetTitleIconImageSource(this, "coffee.png"); SearchBar searchBar = new SearchBar { HeightRequest = 44, WidthRequest = 100 }; // Note: Large and complex controls, such as ListView and TableView, are not recommended. var controls = new List <View> { searchBar, new ActivityIndicator { IsRunning = true }, new BoxView { BackgroundColor = Colors.Red }, new Button { Text = "Button!" }, new DatePicker { }, new Editor { Text = "Editor" }, new Entry { Placeholder = "Entry" }, new Image { Source = "crimson.jpg", HeightRequest = 44 }, new Label { Text = "Title View Label!" }, new Picker { ItemsSource = Enumerable.Range(0, 10).Select(i => $"Item {i}").ToList(), Title = "Picker" }, new ProgressBar { Progress = 50 }, new Slider { }, new Stepper { }, new Switch { }, new TimePicker { } }; int idx = 0; NavigationPage.SetTitleView(this, CreateTitleView(controls[idx])); rootNavPage.On <Android>().SetBarHeight(450); rootNavPage.On <iOS>().SetPrefersLargeTitles(false); Content = new ScrollView { Content = new StackLayout { Children = { new Button { Text = "Go to SearchBarTitlePage", Command = new Command(() => { rootNavPage.PushAsync(new SearchBarTitlePage(rootNavPage)); }) }, new Button { Text = "Change BarTextColor", Command = new Command(() => { if (toggleBarTextColor % 2 == 0) { rootNavPage.BarTextColor = Colors.Teal; } else { rootNavPage.BarTextColor = null; } toggleBarTextColor++; }) }, new Button { Text = "Change BarBackgroundColor", Command = new Command(() => { if (toggleBarBackgroundColor % 2 == 0) { rootNavPage.BarBackgroundColor = Colors.Navy; } else { rootNavPage.BarBackgroundColor = null; } toggleBarBackgroundColor++; }) }, new Button { Text = "Change Both to default", Command = new Command(() => { rootNavPage.BarTextColor = null; rootNavPage.BarBackgroundColor = null; }) }, new Button { Text = "Black background, white text", Command = new Command(() => { rootNavPage.BarTextColor = Colors.White; rootNavPage.BarBackgroundColor = Colors.Black; }) }, new Button { Text = "Toggle TitleIcon", Command = new Command(() => { var titleIcon = NavigationPage.GetTitleIconImageSource(this); if (titleIcon == null) { titleIcon = "coffee.png"; } else { titleIcon = null; } NavigationPage.SetTitleIconImageSource(this, titleIcon); }) }, new Button { Text = "Toggle TitleView", Command = new Command(() => { var titleView = NavigationPage.GetTitleView(this); if (titleView == null) { titleView = CreateTitleView(controls[idx]); } else { titleView = null; } NavigationPage.SetTitleView(this, titleView); }) }, new Button { Text = "Next TitleView", Command = new Command(() => { idx++; if (idx >= controls.Count) { idx = 0; } var titleView = CreateTitleView(controls[idx]); NavigationPage.SetTitleView(this, titleView); }) }, new Button { Text = "Toggle Back Title", Command = new Command(() => { var backTitle = NavigationPage.GetBackButtonTitle(rootNavPage); if (backTitle == null) { backTitle = "Go back home"; } else { backTitle = null; } NavigationPage.SetBackButtonTitle(rootNavPage, backTitle); }) }, new Button { Text = "Toggle Toolbar Item", Command = new Command(() => { if (ToolbarItems.Count > 0) { ToolbarItems.Clear(); } else { ToolbarItems.Add(new ToolbarItem { Text = "Save" }); } }) }, new Button { Text = "Toggle Title", Command = new Command(() => { if (Title == null) { Title = "NavigationBar Gallery - Legacy"; } else { Title = null; } }) }, new Button { Text = "Toggle BarHeight", Command = new Command(() => { if (rootNavPage.On <Android>().GetBarHeight() == -1) { rootNavPage.On <Android>().SetBarHeight(450); } else { rootNavPage.ClearValue(BarHeightProperty); } }) } } } }; }
public HomePage() { InitializeComponent(); _currentViewTitle = NavigationPage.GetTitleView(this); imageNavigation.Source = ImageSource.FromResource("Pokedex.imagesTab.pokedexIcon.png"); }