Skip to main content

CommandAttribute.CanExecuteMethodName Property

Gets or sets the name of the function that defines whether the command can be executed.

Namespace: DevExpress.Mvvm.DataAnnotations

Assembly: DevExpress.Mvvm.v24.1.dll

NuGet Packages: DevExpress.Mvvm, DevExpress.Win.Navigation

Declaration

public string CanExecuteMethodName { get; set; }

Property Value

Type Description
String

A String value that is the function name.

Remarks

The function specified via the CanExecuteMethodName property should return a bool value. The command can be executed only if this function returns true.

public class LoginViewModel {
    [Command(CanExecuteMethodName = "CanSaveAccountSettings",
        Name = "SaveCommand",
        UseCommandManager = true)]
    public void SaveAccountSettings(string fileName) {
        //... 
    }
    public bool CanSaveAccountSettings(string fileName) {
        return !string.IsNullOrEmpty(fileName);
    }
}
See Also