NavigationPage SetTitleIcon not working - Android

Hello i try to add a title image to a Navigation Page, this is my code:

` public class MainPage : ContentPage
{

    public MainPage()
    {


    }
 }        

    public App()
    {

        navPage navTest = new navPage();
        MainPage = navTest;

    }


    public class navPage : NavigationPage
    {


        public navPage()
        {


            var myContentPage = new TabPageHolder();
            this.PushAsync(myContentPage);

            var s = "test.png";
            NavigationPage.SetTitleIcon(this, s);
        }

    }


    public class TabPageHolder : ExtendedTabbedPage
    {

        public TabPageHolder()
        {

            var s = "test.png";
            NavigationPage.SetTitleIcon(this, "test.png");


            ToolbarItems.Add(new ToolbarItem("tst", "settings.png", async () => { }));

            this.Children.Add(_Page01);
            this.Children.Add(_Page02);

            CurrentPageChanged += Mp_CurrentPageChanged;

        }
    }`

https://developer.xamarin.com/api/member/Xamarin.Forms.NavigationPage.SetTitleIcon/

The image is no visible on my NavigationPage any idea what i am doing wrong?
Any help will be much appreciated!

Best Answer

Answers

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Don't try to push a TabbedPage onto a NavigationPage. It's bad design. You should revise your architecture. TabbedPage should be the root while tab items can be navigation pages. I suspect this is causing issues with the icon.

  • XanrenXanren CHMember

    Thank you for your fast feedback.
    I try to create a fixed app title bar this is why i push the TabbedPage into a NavigationPage.
    Is there an other way to achieve this:

    image

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Each tab item should be a navigation page. Then each will have an action bar. Use that as your header. Push your child pages onto their navigation parents.

Sign In or Register to comment.