ViewModel without own view

Topics: Questions
Jul 29, 2014 at 7:47 AM
Hi

In my viewmodel I have a collection of objects and a property to a selected object.
The objects are defined in Database they are only models.

Now I need more details in this object which are only needed for the view. So this details should not be set in the models.

So I added a wrapper arround this class
The properties should also fire propertychanged Events.

So I derive the class from ViewModelbase. And called it ...ViewModel

Thats now my properties in my viewmodel:
public ObservableCollection<HardwareInstancePlaceViewModel> HardwareInstancePlaceViewModels
{
    get { return GetValue<ObservableCollection<HardwareInstancePlaceViewModel>>(HardwareInstancesProperty); }
    set { SetValue(HardwareInstancesProperty, value); }
}

public HardwareInstancePlaceViewModel SelectedHardwareInstancePlaceViewModel
{
    get { return GetValue<HardwareInstancePlaceViewModel>(SelectedHardwareInstancePlaceViewModelProperty); }
    set { SetValue(SelectedHardwareInstancePlaceViewModelProperty, value); }
}
Normaly I use viewmodelinjection in my views.
It's not very beatiful to have a viewmodel in a other viewmodel. Thats the main reasson why I use catel and the nested viewmodel problem.

But I don't know how to solve in this case.
Aug 19, 2014 at 2:15 PM
What people normally do is create a wrapper model around a simplified model. You can do this to either hide members or add additional functionality. It's called the decorator pattern.