I have a ListView like this:
<ListView x:Name="ItemsListView"
ItemsSource="{Binding Items}"
VerticalOptions="FillAndExpand"
HasUnevenRows="true"
RefreshCommand="{Binding LoadItemsCommand}"
IsPullToRefreshEnabled="False"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement"
ItemSelected="OnItemSelected">
and my ViewModel has this definitions and my Model class looks like this:
public ObservableCollection<IncomingJobItem> Items { get; set; }
public class IncomingJobItem
{
public int Index { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("amount")]
public int Amount { get; set; }
}
Now when I update ViewModelObject.Items
and call NotifyPropertyChanged
the already existing items in the ListView do not get updated.
Example:
// change already existing item
ViewModelObject.Items[0].Amount = 3;
// notify item in Items has changed
ViewModelObject.NotifyPropertyChanged("Items");
// nothing happens, item 0 in the list stays with the old amount...
// expected is to update the item in the list to display 3
But when I create and add a new element to ViewModelObject.Items
, the ListView adds the new Item but does not update the already existing item. What can I do?
Also ViewModelObject.NotifyPropertyChanged("Items.Amount");
does nothing.