Search code examples
xamlxamarin.formstextcolortoolbaritems

Changing ToolbarItem text color via xaml to all platform(Android,iOS,UWP)


enter image description hereThis is my xaml code:

ContentPage.ToolbarItems ToolbarItem Text="+" Priority="0" Order="Primary" Command="{Binding PrikaziCommand}" ToolbarItem ContentPage.ToolbarItems

How to change color of text through xaml code to all platform?


Solution

  • If you want to change your toolbar textcolor, you can use Navigation.Titleview

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:local="clr-namespace:TitleViewSample"
                 x:Class="TitleViewSample.MainPage">
    
          <NavigationPage.TitleView>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
    
                <Label Text="Your Title" Grid.Column="0" TextColor="White" FontSize="Large" VerticalOptions="Center" HorizontalOptions="FillAndExpand"></Label>
    
                <StackLayout Grid.Column="1" HorizontalOptions="EndAndExpand" Orientation="Horizontal" Margin="0,5,5,5">
                    <Label Text="?" FontSize="Large" TextColor="Red" Margin="10" ></Label>
                    <Label Text="+" FontSize="Large" TextColor="Green" Margin="10" ></Label>
                </StackLayout>
            </Grid>
    </NavigationPage.TitleView>
    
    
    </ContentPage>
    

    If you want to change the toolbar color add this code when navigating to your specific page

     MainPage = new NavigationPage(new YourPage());
    ((NavigationPage)MainPage).BarBackgroundColor = Color.FromHex("#19110F");
    

    Result