通过 xaml 将 ToolbarItem 文本颜色更改为所有平台(Android、iOS、UWP)

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

enter image description here这是我的 xaml 代码:

ContentPage.ToolbarItems ToolbarItem Text="+" Priority="0" Order="Primary" Command="{Binding PrikaziCommand}" 工具栏项目 ContentPage.ToolbarItems

如何通过 xaml 代码为所有平台更改文本颜色?

如果你想改变你的工具栏文本颜色,你可以使用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>

如果您想更改工具栏颜色,请在导航到您的特定页面时添加此代码

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