Xamarin IOS Shell Itemtemplate Flyout Icon Color

Seth Isaacks 11 Reputation points
2022-02-18T02:37:37.203+00:00

I have an Xamarin Shell flyout application. I am using fontawesome for the icons.
On Android the flyout icons are white...which is perfect...being my background is black
However on IOS, they icons are black. I am not sure why and I cannot get them to change color.
I copied in the style below and the Shell ItemTemplate....pretty much copied from Microsoft Documentation
Why Android the icons are white and IOS they are black, I have no idea, nor can I find a way to change the color that doesnt override the style
I would think the style would apply to the Template but its not.....the icons follow the style on the tab bar in the app.
Essentially I just need help on how to get the color of the Icon changed for IOS.

<ResourceDictionary>
<Color x:Key="NavigationPrimary">#2196F3</Color>
<Style x:Key="BaseStyle" TargetType="Element">
<Setter Property="Shell.BackgroundColor" Value="Black" />
<Setter Property="Shell.ForegroundColor" Value="LightSlateGray" />
<Setter Property="Shell.TitleColor" Value="AliceBlue" />
<Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
<Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
<Setter Property="Shell.TabBarBackgroundColor" Value="Black" />
<Setter Property="Shell.TabBarForegroundColor" Value="AliceBlue"/>
<Setter Property="Shell.TabBarUnselectedColor" Value="LightSlateGray"/>
<Setter Property="Shell.TabBarTitleColor" Value="AliceBlue"/>
</Style>
<Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" />

    </ResourceDictionary>

<!-- ItemTemplate is for ShellItems as displayed in a Flyout-->
<Shell.ItemTemplate>
<DataTemplate>
<ContentView BackgroundColor="Transparent">
<Grid ColumnDefinitions="0.2*,0.8*" Margin="10">
<Image
Margin="5"
HeightRequest="20" Source="{Binding FlyoutIcon}">

                </Image>

                <Label Grid.Column="1"
                   Text="{Binding Title}" 
                   TextColor="LightSlateGray"
                   FontAttributes="Bold"
                   VerticalTextAlignment="Center" />
            </Grid>
        </ContentView>
    </DataTemplate>
</Shell.ItemTemplate>
Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,337 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vanKraster 201 Reputation points
    2022-02-18T15:10:03.857+00:00

    Try to use

     <FontImageSource   
                                        FontFamily="FontAwesomeRegular"
                                        Glyph="{x:Static fontawesome:FontAwesomeIcons.Circle}" 
                                        Color="#2295f3"  />
    

    For Image Source and it is working on both Android and Ios... You can set the color via Color Parameter in FontImageSource.

    Full Working Example is

      <FlyoutItem Title="Categorie"  >
            <FlyoutItem.Icon>
                <FontImageSource   
                                FontFamily="{StaticResource FontAwesomeSolid}"
                                Glyph="{x:Static fontawesome:FontAwesomeIcons.ListOl}" 
                                Size="16" 
                                Color="Black"   />
            </FlyoutItem.Icon>
            <ShellContent Route="CategoryPage" ContentTemplate="{DataTemplate local:CategoryPage}" />
        </FlyoutItem>
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.