Fairly new to MVVM and learing as I go. A little stuck on the proper usage of
. I have the below set up, which compiles, however I am more concerned with, whether, I am using it correctly. I have searched the Online Doc for a while now and couldn't find any examples.
Particularly, I am confused as how I would use the CanSaveAuthorization, or the underlying CanExecute, and what I would do with the object parameter that is required.
Thanks,
Telerik.Windows.Controls DelegateCommand
Particularly, I am confused as how I would use the CanSaveAuthorization, or the underlying CanExecute, and what I would do with the object parameter that is required.
Thanks,
public
class
CreateAuthorizationViewModel : ViewModelBase
{
private
Authorization authorization;
private
AuthorizationRepository authorizationRepository;
private
DelegateCommand saveAuthorizationCommand;
public
DelegateCommand SaveAuthorizationCommand
{
get
{
return
saveAuthorizationCommand;
}
}
public
CreateAuthorizationViewModel()
{
InitializeCommand();
}
private
void
InitializeCommand()
{
saveAuthorizationCommand =
new
DelegateCommand(SaveAuthorization, CanSaveAuthorization);
}
private
void
SaveAuthorization(
object
parameter)
{
authorizationRepository.Save();
}
private
bool
CanSaveAuthorization(
object
parameter)
{
//I would have validation logic here
return
true
;
}
}