Back to Devexpress

CommandAttribute.UseCommandManager Property

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

latest2.5 KB
Original Source

CommandAttribute.UseCommandManager Property

Gets or sets whether to use a function that manages the command execution. This property applies to WPF projects.

Namespace : DevExpress.Mvvm.DataAnnotations

Assembly : DevExpress.Mvvm.v25.2.dll

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

Declaration

csharp
public bool UseCommandManager { get; set; }
vb
Public Property UseCommandManager As Boolean

Property Value

TypeDescription
Boolean

true to use the command manager; otherwise, false.

|

Remarks

The UseCommandManager property specifies whether the Command attribute uses the CommandManager to raise the CanExecuteChanged event.

If you set the UseCommandManager property to true, a CanExecute function is triggered each time a user interacts with the application UI. Otherwise, you should call the RaiseCanExecuteChanged method to update your command.

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);
    }
}

Warning

The CommandAttribute.UseCommandManager property has no effect in DevExpress WinForms MVVM applications. In WinForms apps, call the RaiseCanExecuteChanged method to update the command.

See Also

CanExecuteMethodName

CommandAttribute Class

CommandAttribute Members

DevExpress.Mvvm.DataAnnotations Namespace