© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
9 replies
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();
 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;
 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.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to Properly Synchronize ViewModel and Model in MVVM (CommunityToolkit.Mvvm)
C#CC# / help
11mo ago
❔ MVVM
C#CC# / help
3y ago
MVVM - View model with collection of view models?
C#CC# / help
3y ago
Adding items to an observable collection from 'outside' (MVVM)
C#CC# / help
2y ago