void OnGroceryListChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            // Update item count
            this.ItemCount = this.OBProductList.Count;

            // Resequence list
            SequencingService.SetCollectionSequence(this.OBProductList);
        }
        private void Initialize()
        {
            // Initialize commands
            this.DeleteItem = new DeleteItemCommand(this);

            // Create grocery list
            p_ProductList = new ObservableCollection <Product>();

            // Subscribe to CollectionChanged event
            p_ProductList.CollectionChanged += OnGroceryListChanged;
            // Initialize list index
            this.OBProductList = SequencingService.SetCollectionSequence(this.OBProductList);

            // Update bindings
            base.RaisePropertyChangedEvent("OBProductList");
        }
示例#3
0
        void OnProductListChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            this.ItemCount = this.p_ProductList.Count;

            // Resequence list
            SequencingService.SetCollectionSequence(this.p_ProductList);

            /*
             * double totalPrice = 0;
             * ObservableCollection<Product> obsColl = p_ProductList;
             * foreach (Product data in obsColl)
             * {
             *  double subtotal = data.UnitPrice * data.Quantity;
             *  totalPrice = totalPrice + subtotal;
             * }
             * this._totalPrice = totalPrice;
             */
            base.RaisePropertyChangedEvent("TotalPrice");
        }
示例#4
0
        public ViewModel()
        {
            _totalPrice = 0;
            if (null == p_ProductList)
            {
                GetProductDetails();

                this.AddItem      = new AddItemCommand(this);
                this.PrintInvoice = new PrintInvoiceCommand(this);
                // Create grocery list
                p_ProductList = new ObservableCollection <Product>();

                // Subscribe to CollectionChanged event
                p_ProductList.CollectionChanged += OnProductListChanged;
                // Initialize list index
                this.OBProductList = SequencingService.SetCollectionSequence(this.OBProductList);
                // Update bindings
                base.RaisePropertyChangedEvent("OBProductList");
            }
        }