public void AddChild()
 {
     //IsExpanded = true;
     var subItemViewModel = new SubItemViewModel { Name = "SubItem_" + Children.Count };
     Children.Add(subItemViewModel);
     //subItemViewModel.IsSelected = true;
 }
        private void SubItemsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (SubItemsListBox.SelectedIndex == -1)
            {
                return;
            }

            SubItemViewModel detailsItem = (SubItemViewModel)SubItemsListBox.SelectedItem;

            NavigationService.Navigate(new Uri(string.Format("/Views/CalorieCounterItemDetails.xaml?Calories={0}&Cholestrol={1}&TotalFat={2}&Sodium={3}&TotalCarbs={4}&Protein={5}&Calcium={6}&Potassium={7}&SubItemName={8}&ServingSize={9}",
                                                             detailsItem.Calories, detailsItem.Cholestrol, detailsItem.TotalFat, detailsItem.Sodium,
                                                             detailsItem.TotalCarbs, detailsItem.Protein, detailsItem.Calcium, detailsItem.Potassium, detailsItem.SubItemName, detailsItem.ServingSize), UriKind.Relative));

            SubItemsListBox.SelectedIndex = -1;
        }
Example #3
0
        public static KeyValuePair <ItemModel, ItemModelViewModel> ExistingDestinationComplex()
        {
            var itmId     = Guid.NewGuid();
            var name      = "Item model";
            var itemModel = new ItemModel
            {
                Id       = itmId,
                Name     = string.Format("{0} - CHANGED!", name),
                SubItems = new List <SubItem>()
            };
            var itemModelVm = new ItemModelViewModel
            {
                Id       = itmId,
                Name     = name,
                SubItems = new SubItemViewModel[10]
            };

            for (var i = 0; i < 10; i++)
            {
                var subItemId  = Guid.NewGuid();
                var subItmName = string.Format("Sub item - {0}", i);
                var subItem    = new SubItem
                {
                    Id    = subItemId,
                    Name  = string.Format("{0} - CHANGED!", subItmName),
                    Units = new Unit[4]
                };

                var subItemVm = new SubItemViewModel
                {
                    Id    = subItemId,
                    Name  = subItmName,
                    Units = new Collection <UnitViewModel>()
                };

                itemModel.SubItems.Add(subItem);
                itemModelVm.SubItems[i] = subItemVm;

                for (var j = 0; j < 5; j++)
                {
                    var unitId   = Guid.NewGuid();
                    var unitName = string.Format("Unit - {0}", j);

                    var unit = new Unit
                    {
                        Id       = unitId,
                        Name     = string.Format("{0}, - CHANGED!", unitName),
                        SubUnits = new Collection <SubUnit>()
                    };
                    if (j < 4)
                    {
                        subItem.Units[j] = unit;
                    }

                    var unitVm = new UnitViewModel();

                    unitVm.Id       = unitId;
                    unitVm.Name     = unitName;
                    unitVm.SubUnits = new List <SubUnitViewModel>();
                    subItemVm.Units.Add(unitVm);


                    for (var k = 0; k < 6; k++)
                    {
                        var subUnitId   = Guid.NewGuid();
                        var subUnitName = string.Format("Sub unit - {0}", subUnitId);

                        var subUnit = new SubUnit
                        {
                            Id   = subUnitId,
                            Name = String.Format("{0}, - CHANGED!", subUnitName)
                        };
                        unit.SubUnits.Add(subUnit);
                        if (k < 3)
                        {
                            var subUnitVm = new SubUnitViewModel
                            {
                                Id   = subUnitId,
                                Name = subUnitName,
                            };
                            unitVm.SubUnits.Add(subUnitVm);
                        }
                    }
                }
            }

            return(new KeyValuePair <ItemModel, ItemModelViewModel>(itemModel, itemModelVm));
        }
Example #4
0
        public static KeyValuePair<ItemModel, ItemModelViewModel> ExistingDestinationComplex()
        {
            var itmId = Guid.NewGuid();
            var name = "Item model";
            var itemModel = new ItemModel
            {
                Id = itmId,
                Name = string.Format("{0} - CHANGED!", name),
                SubItems = new List<SubItem>()
            };
            var itemModelVm = new ItemModelViewModel
            {
                Id = itmId,
                Name = name,
                SubItems = new SubItemViewModel[10]
            };

            for (var i = 0; i < 10; i++)
            {
                var subItemId = Guid.NewGuid();
                var subItmName = string.Format("Sub item - {0}", i);
                var subItem = new SubItem
                {
                    Id = subItemId,
                    Name = string.Format("{0} - CHANGED!", subItmName),
                    Units = new Unit[4]
                };

                var subItemVm = new SubItemViewModel
                {
                    Id = subItemId,
                    Name = subItmName,
                    Units = new Collection<UnitViewModel>()
                };

                itemModel.SubItems.Add(subItem);
                itemModelVm.SubItems[i] = subItemVm;

                for (var j = 0; j < 5; j++)
                {
                    var unitId = Guid.NewGuid();
                    var unitName = string.Format("Unit - {0}", j);

                    var unit = new Unit
                    {
                        Id = unitId,
                        Name = string.Format("{0}, - CHANGED!", unitName),
                        SubUnits = new Collection<SubUnit>()
                    };
                    if (j < 4)
                    {
                        subItem.Units[j] = unit;
                    }

                    var unitVm = new UnitViewModel();

                    unitVm.Id = unitId;
                    unitVm.Name = unitName;
                    unitVm.SubUnits = new List<SubUnitViewModel>();
                    subItemVm.Units.Add(unitVm);

                    for (var k = 0; k < 6; k++)
                    {
                        var subUnitId = Guid.NewGuid();
                        var subUnitName = string.Format("Sub unit - {0}", subUnitId);

                        var subUnit = new SubUnit
                        {
                            Id = subUnitId,
                            Name = String.Format("{0}, - CHANGED!", subUnitName)
                        };
                        unit.SubUnits.Add(subUnit);
                        if (k < 3)
                        {
                            var subUnitVm = new SubUnitViewModel
                            {
                                Id = subUnitId,
                                Name = subUnitName,
                            };
                            unitVm.SubUnits.Add(subUnitVm);
                        }
                    }
                }
            }

            return new KeyValuePair<ItemModel, ItemModelViewModel>(itemModel, itemModelVm);
        }