Back to Devexpress

CommandAttribute.CanExecuteMethodName Property

corelibraries-devexpress-dot-mvvm-dot-dataannotations-dot-commandattribute.md

latest1.9 KB
Original Source

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.v25.2.dll

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

Declaration

csharp
public string CanExecuteMethodName { get; set; }
vb
Public Property CanExecuteMethodName As String

Property Value

TypeDescription
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.

csharp
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

CommandAttribute Class

CommandAttribute Members

DevExpress.Mvvm.DataAnnotations Namespace