void BuildMenu() { _lookupTable.Clear(); var menu = Menu; menu.Clear(); var groups = ((IShellController)_shellContext.Shell).GenerateFlyoutGrouping(); int gid = 0; int id = 0; foreach (var group in groups) { foreach (var element in group) { string title = null; BindableObject bindable = null; BindableProperty property = null; if (element is BaseShellItem shellItem) { title = shellItem.Title; bindable = shellItem; property = BaseShellItem.FlyoutIconProperty; } else if (element is MenuItem menuItem) { title = menuItem.Text; bindable = menuItem; property = MenuItem.IconImageSourceProperty; } var item = menu.Add(gid, id++, 0, new Java.Lang.String(title)); if (bindable != null && property != null) { _ = _shellContext.ApplyDrawableAsync(bindable, property, drawable => { item.SetIcon(drawable); }); } } gid++; } }