Search code examples
c#androidmauitextcolor

Change text color in the AppShell in .NET Maui (.NET 8)


I would like to change the text color in the AppShell. Under .NET 6 I had the following implementation in the Styles.xaml, which worked like this:

<Style Class="FlyoutItemLabelStyle"
       TargetType="Label">

    <Setter Property="TextColor"
            Value="White"></Setter>

</Style>

See also the answer here: How to change Flyout ShellContent title text-color in MAUI?

After I upgraded the app to .NET 8, the adjustment of the text colour in the AppShell (under Android) no longer works. Does anyone have an idea how this can be solved?

Screenshot Android AppShell

I want to set FlyoutBackgroundColor to black and TextColor of labels to grey.


Solution

  • There is a known issue about this problem, you can follow it up here: [regression/8.0.3] FlyoutItem and MenuItem styles don't work.

    But you can try the following workaround:

    <Style TargetType="Label" Class="FlyoutItemLabelStyle">
        <Setter Property="VisualStateManager.VisualStateGroups">
            <VisualStateGroupList>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal">
                        <VisualState.Setters>
                            <Setter Property="TextColor" Value="Red" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateGroupList>
        </Setter>
    </Style>