Exemplo n.º 1
0
 private void UpdateListBox()
 {
 goodsLstBox.ItemsSource = null;
 goodsLstBox.Items.Clear();
     var selectedCategory = categoryCmbBox.SelectedItem as ListBoxItem;
     var goods = db.Categories.Find(selectedCategory.Id).GoodsItems.ToList();
     List<ComplexListBoxItem> items = new List<ComplexListBoxItem>();
     foreach (var goodsItem in goods)
     {
         var item = new ComplexListBoxItem(goodsItem.Id, goodsItem.Name, goodsItem.UnitOfMeasure.ShortName);
         items.Add(item);
     }
     goodsLstBox.ItemsSource = items;
     goodsLstBox.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending));
 }
Exemplo n.º 2
0
 private void UpdateComboBoxs()
 {
     categoryCmbBox.ItemsSource = null;
     categoryCmbBox.Items.Clear();
     using (var db = new Model.BudgetModel())
     {
         var categories = db.Categories.ToList();
         List<ListBoxItem> items = new List<ListBoxItem>();
         foreach (var category in categories)
         {
             var item = new ListBoxItem(category.Id, category.Name);
             items.Add(item);
         }
         categoryCmbBox.ItemsSource = items;
     }
     unitOfMeasureCmbBox.ItemsSource = null;
     unitOfMeasureCmbBox.Items.Clear();
     using (var db = new Model.BudgetModel())
     {
         var unitOFMeasures = db.UnitOfMeasures.ToList();
         List <ComplexListBoxItem>items = new List<ComplexListBoxItem>();
         foreach (var unitOFMeasure in unitOFMeasures)
         {
             var item = new ComplexListBoxItem(unitOFMeasure.Id, unitOFMeasure.Name, unitOFMeasure.ShortName);
             items.Add(item);
         }
         unitOfMeasureCmbBox.ItemsSource = items;
     }
 }