shuhelohelo’s blog

Xamarin.Forms多めです.

Xamarin.FormsでNavigationPageのナビゲーションバーの背景色や文字色を変更する

Setting the NavigationBar colors in Xamarin.Formstheconfuzedsourcecode.wordpress.com

NavigationPageのBarBackgroundColorBarTextColorというプロパティで変更することができます.

指定の方法は,C#であればApp.xaml.csでNavigationPageをインスタンス化する際に指定する事ができます.

            MainPage = new NavigationPage(new MainPage())
            {
                BarBackgroundColor = Color.Green[f:id:shuhelohelo:20200313181801p:plain],
                BarTextColor = Color.Yellow,
            };

または,Xaml側でResourceDictionaryにStyleを設定します.

        <ResourceDictionary>
            <Style TargetType="NavigationPage">
                <Setter Property="BarBackgroundColor" Value="Green" />
                <Setter Property="BarTextColor" Value="Yellow" />
            </Style>
        </ResourceDictionary>

これで以下のようにナビゲーションバーの背景色,文字色が変更されます.

f:id:shuhelohelo:20200313181801p:plain