【问题标题】:Xamarin.forms how to Change the Nav Bar Color [duplicate]Xamarin.forms 如何更改导航栏颜色 [重复]
【发布时间】:2016-07-03 21:58:52
【问题描述】:

我正在尝试更改可移植类库项目的导航栏BarBackgroundColor 背景颜色,那么如何更改Xamarin.Forms 上的导航栏颜色

【问题讨论】:

    标签: android xamarin xamarin.forms portable-class-library


    【解决方案1】:

    NavigationPage 有一个您可以设置的BarBackgroundColor 属性。

    https://developer.xamarin.com/api/type/Xamarin.Forms.NavigationPage/

    var nav = new NavigationPage(new ContentPage { Title = "Page" } );
    nav.BarBackgroundColor = Color.Blue;
    

    【讨论】:

    • 我应该在哪里做...它是静态属性..您能否添加一些代码...我收到错误非静态字段、方法或属性需要对象引用'Xamarin.Forms.NavigationPage.BarBackgroundColor.get'
    • BarBackgroundColorProperty 是 BarBackgroundColor 属性的静态支持属性。实例化 NavigationPage 时设置 BarBackgroundColor。
    • 所以我建议你们在 App Class new ex: NavigationPage(new LoginPage()) { BarBackgroundColor = Color.Green }
    • 我添加了一个代码sn-p。
    • @Paul 我会争辩说您的代码不起作用..初始化后您无法更改 BarBackgroundColor 。它被定义为readonly。所以nav.BarBackgroundColor = Color.Blue; 不起作用。但是马克达尔维什代码是正确的。所以如果我的论点是真的,那么请编辑你的主要答案
    猜你喜欢
    • 2017-05-09
    • 1970-01-01
    • 2018-07-21
    • 2018-02-06
    • 1970-01-01
    • 2021-03-10
    • 1970-01-01
    • 2020-07-25
    相关资源
    最近更新 更多