I am doing a cart in xamarin.forms, in my cart page there is a list view with data. Each of the cell containing a button to select the count of item and amount. In the cart view there is a label for grant total, my problem is the grant total is not updating while deleting a item from the cart . The calculation method is on item adding view cell . i know that i need to implement inotifyproperty for this, but i don't know how to do it
I have a base view model which inherit inotifyproperty which contain the event also
public class BaseViewModel : INotifyPropertyChanged{
private double _price;
public double Price{
get { return _price ; }
set{_price =value;OnPropertyChanged("Price");} }
protected virtual void OnPropertyChanged(string propertyName){
if (PropertyChanged != null {
PropertyChanged(this,
new PropertyChangedEventArgs(propertyName));}}
and my view model
public BaseViewModel(){
App.Instance.ViewModel = this;
TempList = TempList ?? new ObservableCollection<cm_items>();
this.Title = AppResources.AppResource.Cart_menu_title;
this. Price = CartCell.price;}
my calculation method
public static double Calculate_price(){
App.Instance.ViewModel.Price = price;
price = 0;
var s = App.Instance.ViewModel.TempList;
var itm_cnt = App.Instance.ViewModel.TempList.Count;
for (int i = 0; i < itm_cnt; i++){
var val1 = s[i].cnt;
var val2 = s[i].item_price;
price += Convert.ToDouble(val1 * val2); }
return pri