void NewControlKit() { controlKitMV = new ControlKitViewModel(new ControlKit()); BindingContext = controlKitMV; _myItems.Clear(); }
public ControlKitXAML(ControlKit controlKit) { _controlKitViewModel = new ControlKitViewModel(controlKit); BindingContext = _controlKitViewModel; InitializeComponent(); }
public EditControlKitXAML(ControlKitViewModel controlKitViewModel) { _controlKitOriginal = new ControlKit(controlKitViewModel.ControlKit); _controlKitViewModel = controlKitViewModel; InitializeComponent(); products = App.Database.GetItems(); foreach (GeStockItem product in products) { ProductPicker.Items.Add(product.Name); } ProductPicker.SelectedIndex = 0; StepperQuantity.Value = quantity; LabelQuantity.Text = quantity.ToString(); GeStockItemCell.showDelete = true; GeStockItemCell.IdMessage = "deleteProductFromControlKit"; _myItems = new ObservableCollection <GeStockItem>(); ObjectsList.ItemsSource = _myItems; ObjectsList.ItemTemplate = new DataTemplate(typeof(GeStockItemCell)); dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(_controlKitViewModel.Elements); foreach (var property in json) { GeStockItem item = App.Database.GetItem(Convert.ToUInt16((string)property.Name)); item.Quantity = Convert.ToUInt16((string)property.Value); _myItems.Add(item); } MessagingCenter.Subscribe <ListView, GeStockItem> (ObjectsList, "deleteProductFromControlKit", (sender, arg) => { _myItems.Remove(arg); }); BindingContext = _controlKitViewModel; }