I have a reasonably large application in C#/WPF made with MVVM (sort of).
In listviews I use the IsSelected bindinded to the selected items. These IsSelected property is located in the model of my app, not in a ViewModel.
Currently I only have one viewmodel pointing to one list in the business object (model, not view model), but in the future I possibly want to change this and than the IsSelected property inside the model is not possible anymore (otherwise both ViewModels would have the same selected items).
The selection mode is multiple and can range between 1 to 128 (max length of list) items.
I think it should be inside the viewmodel somehow, but how should I achieve this?
When using MVVM, you are not restricted to a single view model. Yes, you might expose parts of your model from your view model, but you can also expose other view models.
In this case, I’d recommend wrapping the instances of the collection in their own view model and set the binding root for your item templates to that.
For example, if you were data binding to a collection of models, you could pass the instances of each of those models to a view model that wraps the model and then exposes the
IsSelectedfor binding on the view model.