private void UpdateMenuButtons(ScreenMenuCategory category) { MenuItems = CreateMenuButtons(category, CurrentPageNo, CurrentTag ?? ""); SubCategories.Clear(); SubCategories.AddRange( AppServices.DataAccessService.GetSubCategories(category, CurrentTag) .Select(x => new ScreenSubCategoryButton(x, SubCategoryCommand, category.MButtonColor, category.SubButtonHeight))); if (!string.IsNullOrEmpty(CurrentTag)) { var backButton = new ScreenSubCategoryButton(CurrentTag.Replace(CurrentTag.Split(',').Last(), "").Trim(new[] { ',', ' ' }), SubCategoryCommand, "Gainsboro", category.SubButtonHeight, true); SubCategories.Add(backButton); } if (Categories != null && MenuItems.Count == 0) { if (category.NumeratorType == 2 && SubCategories.Count == 0) { InteractionService.ShowKeyboard(); } MenuItems.Clear(); if (category.MaxItems > 0) { IEnumerable <ScreenMenuItem> sitems = category.ScreenMenuItems.OrderBy(x => x.Order); if (SubCategories.Count == 0) { sitems = Categories.Select(x => x.Category).SelectMany(x => x.ScreenMenuItems); } var items = sitems.Select(x => new ScreenMenuItemButton(x, MenuItemCommand, SelectedCategory)); if (category.SortType == 1) { items = items.OrderByDescending(x => x.UsageCount); } MenuItems.AddRange(items.Take(category.MaxItems)); } } RaisePropertyChanged("MenuItems"); RaisePropertyChanged("IsPageNumberNavigatorVisible"); RaisePropertyChanged("MenuItemsVerticalAlignment"); }
private void OnSubCategoryCommand(ScreenSubCategoryButton obj) { CurrentTag = obj.Name.Trim(); UpdateMenuButtons(SelectedCategory); }