locked
How to change background of MasterDetailPage RRS feed

  • Question

  • User377481 posted

    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.



    Wednesday, October 31, 2018 9:58 AM

All replies

  • User12384 posted

    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.

    Wednesday, October 31, 2018 5:04 PM
  • User377481 posted

    @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


    Thursday, November 1, 2018 1:40 AM
  • User359751 posted

    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

    Thursday, November 1, 2018 12:48 PM
  • User377481 posted

    @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

    Friday, November 2, 2018 8:28 AM
  • User12384 posted

    @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.

    Saturday, November 3, 2018 1:24 PM
  • User377481 posted

    @DinoVukovic thank you , still affecting my layout


    Monday, November 5, 2018 1:02 AM
  • User29117 posted

    @KayKuo, I'm a couple of months late to the thread. Just curious to know, how you were able to solve it?

    Saturday, January 19, 2019 8:02 PM
  • User397388 posted

    add this style in the App.xaml that is

    Friday, November 20, 2020 7:37 PM