When I remove an item from my list, the MvxListView does not refresh.
My list (nothing fancy):
private List<Item> items = new List<Item>();
public List<Item> Items
{
get { return items; }
set { items = value; RaisePropertyChanged(() => Items); }
}
The code that doesn't work:
Items.RemoveAll(x => x.Id == item.Id);
RaisePropertyChanged(() => Items);
Code that does work:
Items = Items.Where(x => x.Id != item.Id).ToList();
It seems like the RaisePropertyChanged() function does not have the desired effect when being called from a isolated function within the viewmodel, but why?
You need to use an ObservableCollection to make the MvxListView update the content.
private ObservableCollection<Item> items = new ObservableCollection<Item>();
public ObservableCollection<Item> Items
{
get { return items; }
set { items = value; RaisePropertyChanged(() => Items); }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With