Esempio n. 1
0
 public Product(string id, string name, decimal price, Variation v)
 {
     this.ID    = id;
     this.Name  = name;
     this.Price = price;
     this.Type  = v;
     AddTax();
 }
        private void comboBoxBikeType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            listBoxProducts.ItemsSource = "";
            Product   selectedProduct = listBoxProducts.SelectedItem as Product;
            Variation selectedItem    = comboBoxBikeType.SelectedItem as Variation;

            if (selectedItem != null)
            {
                for (int i = 0; i < Products.Length; i++)
                {
                    if (Products[i].Variation == selectedItem)
                    {
                        FilteredProducts[i] = (Product)selectedItem;
                    }
                }
            }
            listBoxProducts.ItemsSource = FilteredProducts;
        }
        public MainWindow()
        {
            Variation male = new Variation {
                VarType = "Male"
            };
            Variation female = new Variation {
                VarType = "Female"
            };

            Product aProduct = new Product {
                ID = 1234, Name = "Road Bike", Price = 535.90, Variation = male
            };
            Product bProduct = new Product {
                ID = 4321, Name = "Road Bike", Price = 635.00, Variation = female
            };
            Product cProduct = new Product {
                ID = 5612, Name = "Mountain Bike", Price = 740.00, Variation = male
            };
            Product dProduct = new Product {
                ID = 1511, Name = "Mountain Bike", Price = 780.00, Variation = female
            };
            Product eProduct = new Product {
                ID = 6542, Name = "Hybrid Bike", Price = 155.00, Variation = male
            };
            Product fProduct = new Product {
                ID = 8234, Name = "Hybrid Bike", Price = 204.55, Variation = female
            };

            Products[0] = aProduct;
            Products[1] = bProduct;
            Products[2] = cProduct;
            Products[3] = dProduct;
            Products[4] = eProduct;
            Products[5] = fProduct;

            InitializeComponent();
        }