I would like to change several icons located in the ToolbarItem of a TabbedPage, I've looked at docs here, and I'm either missing the point or maybe what I wish to achieve is not doable?
I'm currently using FontAwesomeIcons to populate icons across my app, and from a static point of view they work great. But in certain scenarios I may wish to change either the icon, or its colour or the icon pack (Light to Solid for example).
App.xaml - I use this to reference my .otf files
<Application.Resources>
<OnPlatform x:Key="FontAwesomeProLight" x:TypeArguments="x:String">
<On Platform="iOS" Value="FontAwesome5Pro-Light" />
</OnPlatform>
<OnPlatform x:Key="FontAwesomeProSolid" x:TypeArguments="x:String">
<On Platform="iOS" Value="FontAwesome5Pro-Solid" />
</OnPlatform>
</Application.Resources>
ExamplePage.xaml - This would be a page where I would show my icons currently (not dynamically)
<TabbedPage.ToolbarItems>
<ToolbarItem Clicked="OnFilterOrders">
<ToolbarItem.IconImageSource>
<FontImageSource FontFamily="{StaticResource FontAwesomeProLight}" Glyph="{x:Static fonts:FontAwesomeIcons.Filter}" />
</ToolbarItem.IconImageSource>
</ToolbarItem>
</TabbedPage.ToolbarItems>
So the code at this point works perfectly to show a static icon, below is my attempt which is failing - but not throwing an error, I just get a ? instead
ExamplePage.xaml
<TabbedPage.ToolbarItems>
<ToolbarItem Clicked="OnFilterOrders">
<ToolbarItem.IconImageSource>
<FontImageSource FontFamily="{DynamicResource FontAwesomeIconPack}" Glyph="{x:Static fonts:FontAwesomeIcons.Filter}" />
</ToolbarItem.IconImageSource>
</ToolbarItem>
</TabbedPage.ToolbarItems>
Using the code-behind of that page, I also have the following in the constructor.
Resources["FontAwesomeIconPack"] = App.Current.Resources["FontAwesomeProLight"];
Am I correct in assuming that Resources["FontAwesomeIconPack"] is linked with the pages resource dictionary, and App.Current.Resources["FontAwesomeProLight"] is linked to the app.xaml page?
I was hoping in this example I would get my existing icon to show, but it doesn't. My expectations is the same icon as before (before I change the pack) but instead I just get a ?).