コード例 #1
0
        void OnRemoveButtonClicked(object sender, EventArgs e)
        {
            var selectedItem       = (CartItem)((Button)sender).CommandParameter;
            var selfBindingContext = (CartPageViewModel)BindingContext;

            selfBindingContext.CartItems.Remove(selectedItem);
            //CartItems.Add(new CartItem { Product = testVar.Product, Qty = testVar.Qty });

            Task.Run(async() => { await ProductCatalogViewModel.SaveCartDataToFile(selfBindingContext.CartItems, ProductCatalogViewModel.CartListFile); }).Wait();
        }
コード例 #2
0
        void OnAddToCartButtonClicked(object sender, EventArgs e)
        {
            var selectedItem       = (ProductCatalog)((Button)sender).CommandParameter;
            var selfBindingContext = (ProductCatalogViewModel)BindingContext;

            selfBindingContext.CartItems.Add(
                new CartItem {
                Product = selectedItem.Product, Qty = selectedItem.Qty, PriceWithCurrency = selectedItem.PriceWithCurrency
            });
            //CartItems.Add(new CartItem { Product = selectedItem.Product, Qty = selectedItem.Qty });

            Task.Run(async() => { await ProductCatalogViewModel.SaveCartDataToFile(selfBindingContext.CartItems, ProductCatalogViewModel.CartListFile); }).Wait();

            //var menuItem = sender as Button;
            //Button button = (Button)sender;
            //var imt = (Grid)button.Parent;
            //var child = imt.Children;
            //var c = (Label)imt.Children[0];
            //var name = c.Text;
            //var c1 = (Stepper)imt.Children[6];
            //var qty = c1.Value;
        }