Have’t you ever got bored of the default colors of the Navigation bar of your applications ?😛 Well I know I did, so as my boss in the new company I’m working for. lol
Enough chit chat! Lemme show you how to change the background color of the default Navigation bar in our awesome Xamarin Forms framework.
Yes it’s crazy simple nowadays, as Xamarin has allowed us to control that from the PCL level itself. But earlier I recall it was pretty complex where we had to write custom renderers and stuff.
How to… from C# code level ?
Xamarin has introduced the following properties for this job, BarBackgroundColor, and BarTextColor. You could easily set these properties for your NavigationPage instance and woahlah ! You are done.
Alright now, hit Run and check it out fellas !
Oh look at that gorgeous NavigationBar… Such an eye-candy view.. lol
Alright looks good… moving on…😛
How to… from XAML code level ?
What if you wanted to set these properties in XAML level ?😀
Well to tell you a little story, the project I’m working now is pretty complex and the architecture is super awesome, that we have to dive massively into MVVM and Architectural design stuff… So we usually keep all the UI related stuff in XAML level.😉 So yeah this is how I originally implemented it, but I did the C# code stuff just to show the separation. End of Storytime ! lol😛
So here’s how to handle this in XAML…
You simply put those values in your global Style level, so when the app is running it will fetch them from those values and set it to the navigation bar.
That’s it… Cheers!
Stay Awesome developers !