How to change Flyout ShellContent title text-color in MAUI?

1.2k Views Asked by At

Please look at my Flyout ShellContents image:

enter image description here

Just wondering, how can I change the text color of shellcontents in Flyout, as I can not find any appropriate foreground/text-color property under ShellContent to change the text color of the title. I have to apply the color from C#. I am making shellcontent pages as mentioned below:

ShellContent _ShellContent = new ShellContent
{
    Title = "Home", 
    ContentTemplate = new DataTemplate(typeof(HomePage)),
    //Route= "HomePage",
     
    Icon = new FontImageSource
    {
        Glyph = Application.Current.Resources["Font-Home"].ToString(),
        FontFamily = "MaterialFontFamily",
        Color = _ShellIconColor
    },
};
    
ShellPages.Items.Add(_ShellContent);

My AppShell.xaml:

<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="myProject.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:myProject"
    xmlns:test="clr-namespace:myProject.Views" 
    Shell.FlyoutBehavior="Flyout" x:Name="ShellPages"> 
        
</Shell>
1

There are 1 best solutions below

4
Alexandar May - MSFT On

According to Style FlyoutItem and MenuItem objects, you can use FlyoutItemLabelStyle to change the text color of shellcontents in Flyout.

Please add below style to your Styles.xaml under Resources\Styles folder in your project.

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

      <Setter Property="TextColor" Value="Red"> </Setter>
        
</Style>

Output:

enter image description here