2016-12-07 18 views
1

与我Xamarin的跨平台应用程序的背景颜色,我有一个与下面的XAML代码创建了一个下拉菜单:Xamarin.Forms改变ContentPage.ToolbarItems

<ContentPage> 
    <ContentPage.ToolbarItems> 
    <ToolbarItem Text="Add another child to my account" Order="Secondary" Priority="1" Clicked="AddAnotherChildClick" /> 
    <ToolbarItem Text="Delete child from my account" Order="Secondary" Priority="2" Clicked="DeleteChildClick" /> 
    <ToolbarItem Text="Log Out" Order="Secondary" Priority="3" Clicked="LogOutClick" /> 
    </ContentPage.ToolbarItems> 
</ContentPage> 

我需要能够控制菜单的背景颜色和文字颜色。它目前是灰色的白色文本(见截图)。我想用橙色文字涂黑。

我该如何改变这一点 - 理想情况下使用全局风格?

Screenshot of the menu as it is now

+0

你是否尝试使用'NavigationPage'方法? –

+0

我导航这样的页面之间:Application.Current.MainPage =新NavigationPage(新我的页面)();你是这个意思吗? –

+0

你创建NavigationPage每次浏览或一次设置您的主要页面NavigationPage和使用推/流行时间?每一次,以防止工作(这是一个要求)后退按钮 –

回答

0

如果您正在使用导航页面,那么你可以做如下:

 var navPage = new NavigationPage(new YourPage()); 
     this.MainPage = navPage; 

     navPage.BarBackgroundColor = Color.Orange; 
     navPage.BarTextColor = Color.Black; 

它会在iOS上,但在Android 5.0及以上的文字颜色不会改变工作。要改变它看到这个链接

How to change navigation bar text color in xamarin forms android