Hi
I have been trying my best to understand this MVVM patten using LLBL. It looks like the problem that I am having has to do with using ObserverableCollection.
Here's what I have
I created a ViewModeBase. Not sure if I need this because I believe that LLBL handles the PropertychangedEvent. So first question is do I really this viewModeBase?
I created a MakeViewModel that looks like this:
public class MakeViewModel : ViewModelBase
{
private MakeFacade mMakeFacade;
public MakeEntity mMakeEntity { get; set; }
public MakeViewModel()
{
mMakeFacade = new MakeFacade(null);
mMakeEntity = mMakeFacade.Get(1);
}
public MakeEntity Make
{
get
{
if (mMakeEntity == null)
{
throw new ArgumentNullException("mMakeEntity");
}
return mMakeEntity;
}
}
Here's my problem with I try to add the MakeViewModel to my MainWindowViewModel I can't seem to add the MakeViewModel
public class MainWindowViewModel : ViewModelBase
{
ObservableCollection<ViewModelBase> mViewModels;
public MainWindowViewModel()
{
MakeViewModel mViewModel = new MakeViewModel();
this.ViewModels.Add(mViewModels); It does not like this
}
public ObservableCollection<ViewModelBase> ViewModels
{
get
{
if (mViewModels == null)
{
mViewModels = new ObservableCollection<ViewModelBase>();
}
return mViewModels;
}
}
Here's my error message
Error 27 The best overloaded method match for 'System.Collections.ObjectModel.Collection<UI.ViewModel.ViewModelBase>.Add(UI.ViewModel.ViewModelBase)' has some invalid argument
Could anyone tell me what I am doing wrong.
Thanks