Home > front end >  Shell FlyoutItem icon from Font Awesome
Shell FlyoutItem icon from Font Awesome

Time:01-04

I am trying to use FontAwesome icons in FlyoutItem as an icon using FontImageSource. I had success in Xamarin Forms with following setup, but for some reason in NET MAUI it does not work (at least on Windows?)? I am seeing tab item, but there is no icon no matter what I try. Is there some way to use Font Awesome icons instead of png pictures?

Example of icon I am trying to use: enter image description here enter image description here

CodePudding user response:

I have got it working way mentioned below. However currently it seems that this solution is working in NET7, but not in NET6. In NET6 there are no icons visible:

enter image description here

  <!-- Desktop/Tablet-->
  <FlyoutItem Title="Home" Icon="{FontImage FontFamily=FontAwesomeSolid, Glyph={x:Static helpers:FontAwesomeIcons.House}, Size=50}">
    <ShellContent ContentTemplate="{DataTemplate page:HomePage}">
      <ShellContent.Icon>
        <FontImageSource FontFamily="FontAwesomeSolid" Glyph="{x:Static helpers:FontAwesomeIcons.House}" Color="White" Size="50"/>
      </ShellContent.Icon>
    </ShellContent>
  </FlyoutItem>
  <FlyoutItem Title="Settings" Icon="{FontImage FontFamily=FontAwesomeSolid, Glyph={x:Static helpers:FontAwesomeIcons.Gear}, Size=50}">
    <ShellContent ContentTemplate="{DataTemplate page:SettingsPage}">
      <ShellContent.Icon>
        <FontImageSource FontFamily="FontAwesomeSolid" Glyph="{x:Static helpers:FontAwesomeIcons.Gear}" Color="White" Size="50"/>
      </ShellContent.Icon>
    </ShellContent>
  </FlyoutItem>
  • Related