I'm trying to change the background color of navigationBar in navigationPage I'm using this code:
using System;
using System;
using Xamarin.Forms;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
namespace P
{
public class App : Application
{
public App ()
{
MainPage = new NavigationPage(new LoginPage());
}
protected override void OnStart ()
{
}
protected override void OnSleep ()
{
}
protected override void OnResume ()
{
// Handle when your app resumes
}
}
}
how can I do it?
Just set the BarBackgroundColor property of the NavigationPage instance:
new NavigationPage(new LoginPage()) { BarBackgroundColor = Color.Green };
If you want to setup a global style in xaml, you could something similar to this:
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Sample.App">
<Application.Resources>
<ResourceDictionary>
<Style TargetType="NavigationPage">
<Setter Property="BarBackgroundColor" Value="#ff5733"/>
<Setter Property="BarTextColor" Value="White"/>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With