maui: Unable to bind `Glyph` property in `FontImageSource` of `ToolbarItem`
Description
Original discussion: https://forums.xamarin.com/discussion/180852/why-glyph-property-in-fontimagesource-doesnt-bind Xamarin issue: https://github.com/xamarin/Xamarin.Forms/issues/12700
This code doesn’t produce any errors, but Glyph is always empty:
<ContentPage.ToolbarItems>
<ToolbarItem IconImageSource="{FontImageSource Glyph={Binding MyIcon}, FontFamily=MaterialDesignIcons}" />
</ContentPage.ToolbarItems>
Static binding works fine. Code above also works if it’s added via Hot Reload (but after proper app reload icon is gone again)

Steps to Reproduce
- Add
ToolbarItemto your page - Specify
IconImageSourceto it asFontImageSourcewith bindedGlyph
Link to public reproduction project repository
Remove the converter and start the app: https://github.com/maxkoshevoi/NureTimetable/blob/5f67cadbb78bc3c37df4985adf8c4ce3a936b4a0/NureTimetable/UI/Views/Timetable/TimetablePage.xaml#L20
Version with bug
6.0.486 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
All (tested on 13)
Did you find any workaround?
Thanks Saskia.
<ToolbarItem IconImageSource="{Binding MyIcon, Converter={converters:ToolbarIconValueConverter}}" />
public class ToolbarIconValueConverter : IValueConverter, IMarkupExtension
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new FontImageSource
{
FontFamily = (OnPlatform<string>)Application.Current.Resources["MaterialFontFamily"],
Glyph = (string)value
};
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
public object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
Relevant log output
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 21 (9 by maintainers)
Sorry I tested it with regular image not with toolbar, but it’s not working with toolbar I’m sorry for that
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows
From: Maksym @.> Sent: Wednesday, November 9, 2022 10:32 AM To: @.> Cc: Michael @.>; @.> Subject: Re: [dotnet/maui] Unable to bind
Glyphproperty inFontImageSourceofToolbarItem(Issue #10186)Yes it’s working without converter
Could you please share a sample project? It doesn’t work on my side as I’ve described here: #10186 (comment)https://github.com/dotnet/maui/issues/10186#issuecomment-1268835353
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/maui/issues/10186#issuecomment-1308391797, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADRJJRWYWAM3APJ7D2AHCS3WHNOTRANCNFSM6AAAAAAQPE72UI. You are receiving this because you were mentioned.Message ID: @.***>
My bad, you were talking about dynamic binding for glyph. Sorry