Пример #1
0
        private void LoadDishMenu()
        {
            IDataService ds     = new XmlDataService();
            var          dishes = ds.GetAllDishes(); // 先把所有菜品读入

            this.DishMenu = new List <DishMenuItemViewModel>();
            foreach (var dish in dishes) // 把每一个viewmodel的菜品添加到DishMenu
            {
                DishMenuItemViewModel item = new DishMenuItemViewModel();
                item.Dish = dish;
                this.DishMenu.Add(item);
            }
        }
Пример #2
0
        private void LoadDishMenu()
        {
            IDataService xmlDataService = new XmlDataService();
            var          dishList       = xmlDataService.GetAllDishes();

            DishMenu = new ObservableCollection <DishMenuItemViewModel>();
            foreach (var item in dishList)
            {
                DishMenuItemViewModel itemViewModel = new DishMenuItemViewModel()
                {
                    Dish = item,
                };
                DishMenu.Add(itemViewModel);
            }
        }
        private void LoadDishMenu()
        {
            XmlDataService xmlData = new XmlDataService();
            var            dishes  = xmlData.GetAllDishes();

            this.DishMenu = new List <DishMenuItemViewModel>();
            foreach (var dish in dishes)
            {
                DishMenuItemViewModel dishMenuModel = new DishMenuItemViewModel()
                {
                    dish = dish
                };

                DishMenu.Add(dishMenuModel);
            }
        }