How to change background of MasterDetailPage

KayKuoKayKuo Member ✭✭✭

I created a masterdetailpage, but I don't know how to change the background at the top. I uploaded the effect I made and the effect I want. Does anyone know how to do it, thank you
and I also uploaded my demo.

Answers

  • DinoVukovicDinoVukovic HRMember ✭✭
    edited October 2018

    Hi KayKuo,

    In your project I haven't found solution to deal with this in shared project. You are overriding xamarin.forms native navigation with third party solution.

    Because of it this line will not work:

    MainPage = new NavigationPage(new MainPage()) { BarTextColor = Color.White, BackgroundColor = Color.FromHex("#95C12B"), BarBackgroundColor = Color.FromHex("#95C12B") };

    Here we deal with navigation bar color.

    You can add/change in your Android project under styles.xml

    <item name="colorPrimary">#2196F3</item>

    For iOS you will deal with this in AppDelegate, so take look at some samples for ios.

    But this will not allow to change colors on some views from your shared code, in case you want pageA goes to red navigation bar and pageB goes with purple.

    Take a look at documentation of xamarin.prism on how to change navigation bar color if there is so. I found it on net but it seems documentation is lacking pointing to your scenario.

  • KayKuoKayKuo Member ✭✭✭
    edited November 2018

    @DinoVukovic thank you ,tried your suggestion:

    <item name="colorPrimary">#2196F3</item>
    

    it can really changed backgroundcolor,But not the effect I want, maybe I mistyped the problem, he will disrupt my layout
    Im using Prism

  • SHUBHAMSHARMA_2927SHUBHAMSHARMA_2927 USMember ✭✭✭

    Hello @KayKuo
    My Suggestion is first Hide the Tabbar through is this code:
    NavigationPage.SetHasNavigationBar(this, false);
    Then putt your own icon on Place where you want and open Master page through IsPeresent Property of MasterDetailPage

  • KayKuoKayKuo Member ✭✭✭

    @SHUBHAMSHARMA_2927 said:
    Hello @KayKuo
    My Suggestion is first Hide the Tabbar through is this code:
    NavigationPage.SetHasNavigationBar(this, false);
    Then putt your own icon on Place where you want and open Master page through IsPeresent Property of MasterDetailPage

    thank you
    it did not work

  • DinoVukovicDinoVukovic HRMember ✭✭

    @KayKuo said:
    @DinoVukovic thank you ,tried your suggestion:

    <item name="colorPrimary">#2196F3</item>
    

    it can really changed backgroundcolor,But not the effect I want, maybe I mistyped the problem, he will disrupt my layout
    Im using Prism

    Use transparent color for background color for sample you want.

  • KayKuoKayKuo Member ✭✭✭

    @DinoVukovic thank you , still affecting my layout

Sign In or Register to comment.