Hi,
New to wpf and MVVM .I am kind of confused what belongs to what.
Lets suppose we have a view with a btnSave.
When saving who's the responsability to call the Business Layer ?
My understanding is that Model is just holding properties and no methods ViewModel is actually implementing EG " DelegateCommand SaveCommand and therefore calling the business layer. However I have been told that is actually responsability of the Model to call the business layer.
example taken from josh smith on msdn
Extract from there
public ICommand SaveCommand
{
get
{
if (_saveCommand == null)
{
_saveCommand = new RelayCommand(param => Save(),param => CanSave);
}
return _saveCommand;
}
}
/// <summary>
/// Saves the customer to the repository. This method is invoked by the SaveCommand.
/// </summary>
private void Save()
{
if (!_customer.IsValid)
throw new InvalidOperationException(Strings.CustomerViewModel_Exception_CannotSave);
if (this.IsNewCustomer)
_customerRepository.AddCustomer(_customer);
base.OnPropertyChanged("DisplayName");
}
Your views very much appreciated.