コード例 #1
0
        /// <summary>
        /// Description: This method adds the InventoryTracker user control to the wrap panel
        /// </summary>
        private void AddCarInventory()
        {
            InventoryTracker car1 = new InventoryTracker
            {
                ctrlName       = "Honda",
                ctrlStartValue = InventoryDb.Honda.ToString()
            };
            InventoryTracker car2 = new InventoryTracker
            {
                ctrlName       = "Mazda",
                ctrlStartValue = InventoryDb.Honda.ToString()
            };
            InventoryTracker car3 = new InventoryTracker
            {
                ctrlName       = "Ford",
                ctrlStartValue = InventoryDb.Honda.ToString()
            };
            InventoryTracker car4 = new InventoryTracker
            {
                ctrlName       = "Nissan",
                ctrlStartValue = InventoryDb.Honda.ToString()
            };

            uiInventory.Children.Add(car1);
            uiInventory.Children.Add(car2);
            uiInventory.Children.Add(car3);
            uiInventory.Children.Add(car4);
        }
コード例 #2
0
 /// <summary>
 /// Description: This is the dispatcherTimer event handler. It displays the new car inventory
 /// everytime the dispatcherTimer ticks.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dispatcherTimer_Tick(object sender, EventArgs e)
 {
     foreach (FrameworkElement fe in uiInventory.Children)
     {
         if (fe is InventoryTracker)
         {
             InventoryTracker car = (InventoryTracker)fe;
             car.ctrlCurrentValue = InventoryDb.GetInventory(car.ctrlName).ToString();
         }
     }
 }