如何在 Xamarin 表单 NavigationPage 中更改背景颜色 [英] How to change backGround color in Xamarin forms NavigationPage

查看:33
本文介绍了如何在 Xamarin 表单 NavigationPage 中更改背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改导航页面中导航栏的背景颜色我正在使用以下代码:

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
    }
   }
  }

我该怎么做?

推荐答案

只需设置NavigationPage实例的BarBackgroundColor属性即可:

Just set the BarBackgroundColor property of the NavigationPage instance:

new NavigationPage(new LoginPage()) { BarBackgroundColor = Color.Green };

这篇关于如何在 Xamarin 表单 NavigationPage 中更改背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆