Xaml 我在Xamarin Forms App.Shell中的颜色配置缺少什么?

Xaml 我在Xamarin Forms App.Shell中的颜色配置缺少什么?,xaml,xamarin,xamarin.forms,xamarin.forms.shell,.net-standard-2.1,Xaml,Xamarin,Xamarin.forms,Xamarin.forms.shell,.net Standard 2.1,今天早些时候,我在这里寻求帮助,因为我的Xamarin应用程序没有像我预期的那样工作。 在获得了关于如何更改动作栏颜色的帮助后,我开始思考“为什么我发现教程中的说明不起作用” 编辑 <?xml version="1.0" encoding="UTF-8"?> <Shell xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://sche

今天早些时候,我在这里寻求帮助,因为我的Xamarin应用程序没有像我预期的那样工作。 在获得了关于如何更改动作栏颜色的帮助后,我开始思考“为什么我发现教程中的说明不起作用”

编辑

<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
   xmlns:local="clr-namespace:Mobile.XamarinApp.Views"
   xmlns:sys="clr-namespace:System;assembly=netstandard"
   x:Class="Mobile.XamarinApp.AppShell"
   BackgroundColor="{StaticResource Primary}"
   Shell.ForegroundColor="{StaticResource Background}"
   Shell.TitleColor="{StaticResource Background}">
<!--
    The overall app visual hierarchy is defined here, along with navigation.
    https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
-->
<Shell.Resources>
    <ResourceDictionary>
        <Style x:Key="BaseStyle" TargetType="Element" ApplyToDerivedTypes="True">
            <Setter Property="Shell.Title" Value="App" />
            <Setter Property="Shell.BackgroundColor" Value="{StaticResource Background}" />
            <Setter Property="Shell.ForegroundColor" Value="{StaticResource Primary}" />
            <Setter Property="Shell.TitleColor" Value="{StaticResource Primary}" />
            <Setter Property="Shell.DisabledColor" Value="HotPink" />
            <Setter Property="Shell.UnselectedColor" Value="{StaticResource Secondary}" />
            <Setter Property="Shell.TabBarBackgroundColor" Value="Red" />
            <Setter Property="Shell.TabBarForegroundColor" Value="Blue"/>
            <Setter Property="Shell.TabBarUnselectedColor" Value="Green"/>
            <Setter Property="Shell.TabBarTitleColor" Value="Yellow"/>
            <Setter Property="Shell.FlyoutHeight" Value="400"/>
            <Setter Property="Shell.FlyoutWidth" Value="200"/>
        </Style>
        
        <Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
        <Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
    
        <!--
        Default Styles for all Flyout Items
        https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/flyout#flyoutitem-and-menuitem-style-classes
        -->
        <Style Class="teste" TargetType="TabbedPage">
            <Setter Property="BackgroundColor" Value="Red"/>
        </Style>
        <Style Class="FlyoutItemLabelStyle" TargetType="Label">
            <Setter Property="TextColor" Value="{StaticResource Accent}"></Setter>
        </Style>
        <Style Class="FlyoutItemLayoutStyle" TargetType="Layout" ApplyToDerivedTypes="True">
            <Setter Property="BackgroundColor" Value="{StaticResource Primary}"></Setter>
            <Setter Property="HeightRequest" Value="50" />
            <Setter Property="HorizontalOptions" Value="Start"/>
            <Setter Property="VisualStateManager.VisualStateGroups">
                <VisualStateGroupList>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal">
                            <VisualState.Setters>
                                <Setter Property="BackgroundColor" Value="{StaticResource Primary}" />
                            </VisualState.Setters>
                        </VisualState>
                        <VisualState x:Name="Selected">
                            <VisualState.Setters>
                                <Setter Property="BackgroundColor" Value="{StaticResource Secondary}" />
                                <Setter TargetName="FlyoutItemLabel" Property="Label.TextColor" Value="White" />
                            </VisualState.Setters>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateGroupList>
            </Setter>
        </Style>
        <!--
        Custom Style you can apply to any Menu Item
        -->
        <Style Class="MenuItemLayoutStyle" TargetType="Layout" ApplyToDerivedTypes="True">
            <Setter Property="VisualStateManager.VisualStateGroups">
                <VisualStateGroupList>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal">
                            <VisualState.Setters>
                                <Setter TargetName="FlyoutItemLabel" Property="Label.TextColor" Value="{StaticResource Accent}" />
                            </VisualState.Setters>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateGroupList>
            </Setter>
        </Style>
    </ResourceDictionary>
</Shell.Resources>

<Shell.FlyoutHeaderTemplate>
    <DataTemplate>
        <Grid BackgroundColor="{StaticResource Secondary}" HeightRequest="56" Padding="10,0,10,0">
            <Label Text="Menu"
               TextColor="{StaticResource Primary}"
               FontAttributes="Bold"
               VerticalTextAlignment="Center"
                   HorizontalTextAlignment="Start"/>
        </Grid>
    </DataTemplate>
</Shell.FlyoutHeaderTemplate>

<Shell.FlyoutFooterTemplate>
    <DataTemplate>
        <StackLayout>
            <Label Text="Xaminals"
               TextColor="Black"
               FontAttributes="Bold"
               HorizontalOptions="Center" />
            <Label Text="{Binding Source={x:Static sys:DateTime.Now}, StringFormat='{0:MMMM dd, yyyy}'}"
               TextColor="Black"
               HorizontalOptions="Center" />
        </StackLayout>
    </DataTemplate>
</Shell.FlyoutFooterTemplate>

<!-- Splash Screen/Start Page -->
<!--<ShellItem Route="loading">
    <ShellContent ContentTemplate="{DataTemplate local:LoadingPage}" />
</ShellItem>-->

<!-- SignIn Page -->
<ShellContent Route="SignInPage" ContentTemplate="{DataTemplate local:SignInPage}"/>
<!-- 
    When the Flyout is visible this defines the content to display in the flyout.
    FlyoutDisplayOptions="AsMultipleItems" will create a separate flyout item for each child element    
    https://docs.microsoft.com/dotnet/api/xamarin.forms.shellgroupitem.flyoutdisplayoptions?view=xamarin-forms
-->
<FlyoutItem Title="Browse">
    <ShellContent Route="ItemsPage" ContentTemplate="{DataTemplate local:ItemsPage}" />
</FlyoutItem>
<FlyoutItem Title="About">
    <ShellContent Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</FlyoutItem>
<FlyoutItem Title="Cadastro">
    <ShellContent Route="ItemsPage" ContentTemplate="{DataTemplate local:ItemsPage}" />
</FlyoutItem>

<!-- When the Flyout is visible this will be a menu item you can tie a click behavior to  -->
<MenuItem Text="Sair" StyleClass="MenuItemLayoutStyle" Clicked="OnSignOutMenuItemClicked">
</MenuItem>

<!--
    TabBar lets you define content that won't show up in a flyout menu. When this content is active
    the flyout menu won't be available. This is useful for creating areas of the application where 
    you don't want users to be able to navigate away from. If you would like to navigate to this 
    content you can do so by calling 
    await Shell.Current.GoToAsync("//LoginPage");
-->

<!-- Optional Templates 
// These may be provided inline as below or as separate classes.

// This header appears at the top of the Flyout.
// https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/flyout#flyout-header
<Shell.FlyoutHeaderTemplate>
    <DataTemplate>
        <Grid>ContentHere</Grid>
    </DataTemplate>
</Shell.FlyoutHeaderTemplate>

// ItemTemplate is for ShellItems as displayed in a Flyout
// https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/flyout#define-flyoutitem-appearance
-->
<!--<Shell.ItemTemplate>
    <DataTemplate>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Label Grid.Column="0"
                   Text="{Binding Title}"
                   FontAttributes="Italic"
                   VerticalTextAlignment="Center" />
        </Grid>
    </DataTemplate>
</Shell.ItemTemplate>-->
<!--
// MenuItemTemplate is for MenuItems as displayed in a Flyout
// https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/flyout#define-menuitem-appearance
-->
<!--<Shell.MenuItemTemplate>
    <DataTemplate>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Label Grid.Column="0"
                   Text="{Binding Text}"
                   FontAttributes="Italic"
                   VerticalTextAlignment="Center" />
        </Grid>
    </DataTemplate>
</Shell.MenuItemTemplate>-->
问题是,我做错什么了吗?我错过什么了吗

我只想从Shell中更改我的
选项卡栏
、操作栏等的颜色。参考资料字典如教程所示


提前感谢

您可能还需要针对
外壳内容
键入:

<Style TargetType="ShellContent" BasedOn="{StaticResource BaseStyle}"/>


只是一个猜测,不确定您到底想要实现什么,您是否尝试添加了
TargetType=“ShellContent”BasedOn=“{StaticResource BaseStyle}”/>
?@Cfun这正是我想要的!谢谢你能回答吗?
   BackgroundColor="{StaticResource Primary}"
   Shell.ForegroundColor="{StaticResource Background}"
   Shell.TitleColor="{StaticResource Background}"
<Style TargetType="ShellContent" BasedOn="{StaticResource BaseStyle}"/>