This question is a continuation of this older one , and it is more a confirmation than an open question.
In my ViewModel instance is a particular instance of the model _modelInst.
ViewModel has exclusive access to model data during editing (therefore, models do not need to implement INotifyPropertyChanged).
Now there are three ways I came up with how to edit model data from a view:
Getting / setting directly in the model
instance for example for simple value fields
return _modelInst.fieldname;
_modelInst.fieldname = value;
This easy to use ...
Creating an instance of ViewModel and working with the parent data structure,
for example, for more complex types of objects, such as structs:
- Create a new ViewModel for this type.
ViewModel knows the parent and its field name. - maps this to ContentControl + DataTemplate
- receiving / setting:
through the methods of the parent with the fieldname parameter as a parameter,
overwriting the entire source object, even if only one field is changed.
This means that for each of these structures a new interface is created (with update procedures working on _modelInst) implemented by the parent.
Creating ViewModel instances without directly knowing the structure of the parent data,
for example for (lists) of classes inside parent classes
(4.) ViewModel, ,
subobject (+ , ).
.
_modelInst.
( ) ?
MVVM ()?
MVVM ?