I am making an application for a basket, I need to change the image in the addToCart button. I have a + button in the form of a list, and I add an item to the basket so that the image changes to "-". when I remove an item from my recycle bin, the image again changes to "+". I hope that here I also need to be notified, but how to implement it here. I have a Boolean property. My logic is “change the boolean value when adding and removing, but I don’t know how to change the image to a button”, this is my view model
public BaseViewModel(){
App.Instance.ViewModel = this;
TempList = TempList ?? new ObservableCollection<cm_items>();
this.Title = AppResources.AppResource.Cart_menu_title;
this.IsContain = CartCell.buttonImg();
TempList.CollectionChanged += (sender, args) =>{
this.Price = CartCell.Calculate_price();};}
and my property
private bool _isContain;
public bool IsContain
{
get { return _isContain; }
set {_isContain=value;OnPropertyChanged("IsContain");}
}
and converter
public class BoolToImageConverter : IValueConverter
{
#region IValueConverter implementation
public object Convert (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is bool) {
if((bool)value == true)
return "add.png";
else
return "minus.png";
}
return "";
}
public object ConvertBack (object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException ();
}
#endregion
}
but still i have no image in the button
user4318551
source
share