C#C
C#15mo ago
Kek

MVVM should model items have INotify?

Very basic question but I am conflicted.
I have a viewmodel
 public partial class HsSelectedItemViewModel : BaseViewModel
 {
     public long? BarCode { get; set; } = -1;
     public ObservableCollection<HSItemFull> Items { get; set; } = new();

The ui is a listview with items as itemsource and the items are shown with their details.
Now when I add to Items it will update the ui ofc, but when I change a property of an item I also want to show it in the ui. I can do this by adding
 public partial class HSItemFull : ObservableObject, INotifyPropertyChanged
 {
     public string UUID { get; set; } = "NOT SET";
     DateTime expires;
     [ObservableProperty]
     DateTime accuired;


My only logical issue is that the HSItemFull is in the model. Whats the common way to handl this, is it stupid to add Observable property to model classes? The other way I see is to copy this item into one at viewmodel which seems more stupid.
Was this page helpful?