I have a menu that displays the items from the observable collection from this class :
class DeHavMenu
{
private string foodName;
private double price;
public string FoodName
{
get {return foodName; }
set { foodName = value; }
}
public double Price
{
get {return price;}
set { price = value; }
}
public DeHavMenu(string f, double p)
{
this.foodName = f;
this.price = p;
}
public override string ToString()
{
return (this.FoodName + " Price: £" + this.Price);
}
}
Now on the menu page , I add the items on the page to display it on the list view:
public sealed partial class DeHavillandMenu : Page
{
private ObservableCollection<DeHavMenu> menuItems = new ObservableCollection<DeHavMenu>();
public DeHavillandMenu()
{ this.InitializeComponent();
MenuList.SelectionMode = ListViewSelectionMode.Multiple;
this.menuItems = new ObservableCollection<DeHavMenu>();
this.menuItems.Add(new DeHavMenu("Sausage/Bacon roll and hot drink", 2.25));
this.menuItems.Add(new DeHavMenu("5 item cooked breakfast and hot drink", 2.75));
this.menuItems.Add(new DeHavMenu("Pizza with selection of pasta, wedges and garlic bread", 4.25));
this.menuItems.Add(new DeHavMenu("Baked / grilled Halal chicken with piri piri", 6.50));
this.menuItems.Add(new DeHavMenu("Baked / grilled Halal chicken with tandoori", 6.50));
MenuList.DataContext = menuItems;
}
}
The menu page displays the items fine, can select multiple items fine, but cannot find the solution to calculate the total price by taking the sum of the selected items.
I know using Menulist.selecteditems.price
is appropriate, but it does not give me the option to.
Thanks in advance.