Hi community.
I have a strange behavior with FontImageSource. I can't get property binded to Glyph.
<ContentPage.BindingContext> <documents:DocumentListViewModel /> </ContentPage.BindingContext> <ContentPage.ToolbarItems> <ToolbarItem Command="{Binding ChangeViewTypeCommand, Mode=OneWay}"> <ToolbarItem.IconImageSource> <FontImageSource Glyph="{Binding ViewTypeGlyph}" Size="26" FontFamily="{x:StaticResource MaterialFontFamily}" Color="{DynamicResource PrimaryColor}"/> </ToolbarItem.IconImageSource> </ToolbarItem> </ContentPage.ToolbarItems> public string ViewTypeGlyph { get { switch (this.ViewType) { case ViewType.SmallRows: return MaterialDesignIcons.ViewAgendaOutline; case ViewType.BigRows: return MaterialDesignIcons.CropSquare; case ViewType.Grid: return MaterialDesignIcons.ViewGridOutline; } return MaterialDesignIcons.ViewAgendaOutline; } }
I put a break point on the get block and it does not raise.
What am I missing?
Note: setting Glyph to static property works as well
<FontImageSource Glyph="{x:Static icons:MaterialDesignIcons.ViewAgendaOutline}" Size="26" FontFamily="{x:StaticResource MaterialFontFamily}" Color="{DynamicResource PrimaryColor}"/>
Answers
Uploading your code may help us more to help you solve the problem.
@Tracy320 I have created a small repro project.
There are 2 toolbar items (first is an Icon with Glyph from binding, second is an Icon with Glyph from static class) in ItemsPage.
So the result is:
As you can see, an Icon with binding is not showing.
Thank you for posting in Developer Community.I am doing some research to investigate your problem. And I’ll get back to you as soon as I have an update. Much appreciated for your patience.
Hi. Is there any updates on this issue? Thanks
Hi, any updates on this? I can confirm this bug.
Binding works properly on Labels for instante. But it simply does not work in Toolbar items.
This works:
<Label BackgroundColor="#424242"
This does not:
In the c# code my SaveIconFont = "\uf09c"; So it's in the correct format. It just shows the box with a cross icon (not found or something).
I'm afraid this looks like another half cooked feature. I've searched all over the net, I haven't found a single example binding a font to a ToolbarItem successfully.
If you've found an answer please let me know.
Same issue here. Any updates?
I don't know if you can use this, but I solved it by using a converter:
item.SetBinding(ToolbarItem.IconImageSourceProperty, new Binding("ToolbarIcon", converter: new ToolbarIconValueConverter()));
Having the same issue. Created a GitHub issue for this. Maybe it will get resolved faster this way:
github com/xamarin/Xamarin.Forms/issues/12700 (cannot post links)