ToolbarItemBadgeSample
ToolbarItemBadgeSample copied to clipboard
xamarin forms + mvvmcross can't show badge in ios
xamarin forms + mvvmcross can't show badge in ios
Is anyone has the answer?
I do find a solution for the iOS that you may try to see if it works for you when calling the ToolbarItemBadgeService.SetBadge method in the ViewModel
var page = App.Current.MainPage.Navigation.NavigationStack.LastOrDefault();
var item = page.ToolbarItems.LastOrDefault(); // not necessary the last one
var count = //code to get the count number...
ToolbarItemBadgeService.SetBadge(page, item, count, Color.Red, Color.White);
At first, I only use App.Current.MainPage but when accessing the ToolbarItems, it has zero counts. It seems only App.Current.MainPage.Navigation.NavigationStack.LastOrDefault() returns the real current active page with the toolbar items.