what is best practice to make a DelegateCommand
from Prism
framework in MVVM
only one time executable in order to prevent click-spamming the button which may result in application crashes.
many thanks!
Here is what I normally do:
here is an example
private Class object;
public Class Object
{
get { return object; }
set { SetProperty(ref object, value); }
}
private DelegateCommand _delete;
public DelegateCommand Delete =>
_delete ?? (_delete = new DelegateCommand(ExecuteDelete, CanExecuteDelete)).ObservesProperty(()=> Object);
void ExecuteDelete()
{
MyServices.Delete(Object);
Object = null;
}
bool CanExecuteDelete()
{
return Object != null;
}