question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] [Android] ShellContentPage ContentPage.ToolbarItem not rendering

See original GitHub issue

Description

Adding a toolbaritem to ContentPage of ShellContent Route not showing at toolbar. When navigate using bottom navigation of Shell TabBar at Android, ToolBarItem show a blink and disappear.

Steps to Reproduce

  1. Create new Maui project
  2. Add new Xaml-Page
  3. Add ContentPage.ToolbarItems to the newly created page
  4. Replace content of MainPage with a Shell
  5. Add the xml-Namespace xmlns:local=“clr-namespace:cvmaker”
  6. Add Tab to the Shell with ShellContent ContentTemplate=“{DataTemplate local:HomePage}”

Version with bug

Preview 10 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 11

Did you find any workaround?

no

Relevant log output

no

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Epictekcommented, Jan 4, 2022

I discovered a workaround for this, It seems adding the ToolbarItems after the page has rendered works.

        protected override void OnAppearing()
        {
            base.OnAppearing();

            _ = Task.Run(async () =>
            {
                await Task.Delay(1000);
                
                MainThread.BeginInvokeOnMainThread(() => {
                    this.ToolbarItems.Clear();
                    this.ToolbarItems.Add(new ToolbarItem() { IconImageSource = new FontImageSource() { Glyph = "\ue145", FontFamily="MaterialIcons" } , Text = "Add", Command = ((ListPageViewModel)BindingContext).AddCommand });
                    });

            });
        }
0reactions
sharpwoodcommented, Mar 31, 2022

Did you test it use Shell ContentPage? Shell ! @PureWeen

Read more comments on GitHub >

github_iconTop Results From Across the Web

xaml - ToolbarItem is not showing
The ToolbarItems needs a Navigation Page to show them up. So modify MainPage wrapped by a navigation page: ... ToolbarItems> <ContentPage.
Read more >
Toolbar image icons not displaying (Android) - Microsoft Q&A
It seems to be a problem with the toolbar. I've seen some others have this same issue in other forums. How can I...
Read more >
Shell Content page destruction - Xamarin.Forms - RSSing.com
Using 4.3, say I have 3 tab items, each of them having 2 ShellContent items. I am using ContentTemplate to only create the...
Read more >
[Code]-Check content of T item C# - appsloveworld.com
var item = (WrappedSelection<Projects>)arg);. But a better solution would be to change the signature of the method so the argument is of the...
Read more >
Untitled
Forms Shell - Xamarin Microsoft Learn xml - Xamarin throw error : No view ... /how-can-i-obtain-current-shell-content-page-reference-in-xamarin-app-shell ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found