private void DataBinding(List <VarorModel> list) { shoppingListListBoxBinding.DataSource = list; shoppingListListBox.DataSource = shoppingListListBoxBinding; shoppingListListBox.ValueMember = "Display"; shoppingListListBox.DisplayMember = "Display"; dyrasteBinding.DataSource = VarorProcessor.MostExpensive(list); dyrasteListBox.DataSource = dyrasteBinding; billigasteBinding.DataSource = VarorProcessor.Cheapest(list); billigasteListBox.DataSource = billigasteBinding; dyrasteListBox.ValueMember = "Display"; dyrasteListBox.DisplayMember = "Display"; billigasteListBox.ValueMember = "Display"; billigasteListBox.DisplayMember = "Display"; summaBinding.DataSource = VarorProcessor.Sum(list); summaListBox.DataSource = summaBinding; shoppingListListBoxBinding.ResetBindings(false); dyrasteBinding.ResetBindings(false); billigasteBinding.ResetBindings(false); }
private void DataBinding(List <VarorModel> list) { varorListBox.ItemsSource = list; varorListBox.DisplayMemberPath = "Display"; var mostExpensive = VarorProcessor.MostExpensiveModel(list); dyrasteVara.Text = $"{mostExpensive.Name} - Pris: {mostExpensive.Price} kr"; var cheapest = VarorProcessor.CheapestModel(list); billigasteVara.Text = $"{cheapest.Name} - Pris: {cheapest.Price} kr"; summaTextBox.Text = $"{VarorProcessor.Sum(list).ToString()} kr"; }
public static void OutputSumCheapestExpensive() { Console.WriteLine($"\nSumma i korgen: {VarorProcessor.Sum(VarorModel.listOfVaror)} kr"); Console.WriteLine($"\nBilligaste vara/varor:"); foreach (var item in VarorProcessor.Cheapest(VarorModel.listOfVaror)) { Console.WriteLine($"{item.Name} - Pris: {item.Price}"); } Console.WriteLine($"\nDyraste vara/varor:"); foreach (var item in VarorProcessor.MostExpensive(VarorModel.listOfVaror)) { Console.WriteLine($"{item.Name} - Pris: {item.Price}"); } }