ossentoo ossentoo - 1 year ago 86
C# Question

How to set BarBackgroundColor for all views?

I've got an MvvmCross Xamarin Forms application that I'm developing for iOS and Android.

I'm trying to set the

BarBackgroundColor = Color.FromHex("F26C4F")

for all views (with NavigationPage) in one common place. If i was using straight Xamarin Forms, I would perhaps have a base class inheriting from NavigationPage and then setup the stylings in the base class constructor.

However, I'm lost because with MvvmCross, a lot of the startup code is in the iOS project. All I have in the Xamarin Forms project is:

public override void Initialize()


in the App.cs class.

So, what's the best way of applying common styling (ideally to both app builds) in an MvvmCross Xamarin Forms application?

It would be handy to have a code snippet please.


Answer Source

You could use the UIAppearance API on iOS and Styles on Android to do this. Though it would be platform specific.


UINavigationBar.Appearance.BarTintColor = UIColor.Blue;


<item name="android:navigationBarColor">@color/primary_white</item>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download