What Changed
In v20.1 and earlier versions, the IDelegateCommand and IAsyncCommand interfaces were in a namespace for internal use - DevExpress.Mvvm.Native.
In v20.2, we have moved these interfaces to the public DevExpress.Mvvm namespace.
Currently the declaration is as follows:
C#namespace DevExpress.Mvvm {
public interface IDelegateCommand : ICommand {
void RaiseCanExecuteChanged();
}
public interface IAsyncCommand : IDelegateCommand {
bool IsExecuting { get; }
CancellationTokenSource CancellationTokenSource { get; }
bool IsCancellationRequested { get; }
ICommand CancelCommand { get; }
Task ExecuteAsync(object parameter);
//Legacy and hidden API
[EditorBrowsable(EditorBrowsableState.Never)]
bool ShouldCancel { get; }
//Legacy and hidden API
[EditorBrowsable(EditorBrowsableState.Never)]
void Wait(TimeSpan timeout);
}
}
Visual BasicNamespace DevExpress.Mvvm
Interface IDelegateCommand
Inherits ICommand
Sub RaiseCanExecuteChanged()
End Interface
Interface IAsyncCommand
Inherits IDelegateCommand
ReadOnly Property IsExecuting As Boolean
ReadOnly Property CancellationTokenSource As CancellationTokenSource
ReadOnly Property IsCancellationRequested As Boolean
ReadOnly Property CancelCommand As ICommand
Function ExecuteAsync(ByVal parameter As Object) As Task
'''Legacy And hidden API
<EditorBrowsable(EditorBrowsableState.Never)>
ReadOnly Property ShouldCancel As Boolean
'''Legacy And hidden API
<EditorBrowsable(EditorBrowsableState.Never)>
Sub Wait(ByVal timeout As TimeSpan)
End Interface
End Namespace
Reasons for Change
We have public functions that return an IDelegateCommand or IAsyncCommand object. In previous versions, public APIs returned objects declared in a namespace for internal use (DevExpress.Mvvm.Native):
C#namespace DevExpress.Mvvm.POCO {
public static class POCOViewModelExtensions {
...
public static IDelegateCommand GetCommand<T>(this T viewModel, Expression<Action<T>> methodExpression) { ... }
public static IAsyncCommand GetAsyncCommand<T>(this T viewModel, Expression<Func<T, Task>> methodExpression) { ... }
}
}
Visual BasicNamespace DevExpress.Mvvm.POCO
Module POCOViewModelExtensions
...
<Extension()>
Function GetCommand(Of T)(ByVal viewModel As T, ByVal methodExpression As Expression(Of Action(Of T))) As IDelegateCommand
...
End Function
<Extension()>
Function GetAsyncCommand(Of T)(ByVal viewModel As T, ByVal methodExpression As Expression(Of Func(Of T, Task))) As IAsyncCommand
...
End Function
End Module
End Namespace
These functions are used in POCO ViewModels. In addition to these methods, we implemented similar functions in ViewModelBase in v20.2:
C#namespace DevExpress.Mvvm {
public abstract class ViewModelBase : BindableBase {
...
protected IDelegateCommand GetCommand(Expression<Action> commandMethodExpression) { ... }
protected IAsyncCommand GetAsyncCommand(Expression<Func<Task>> commandMethodExpression) { ... }
}
}
Visual BasicNamespace DevExpress.Mvvm
Public MustInherit Class ViewModelBase
Inherits BindableBase
...
Protected Function GetCommand(ByVal commandMethodExpression As Expression(Of Action)) As IDelegateCommand
...
End Function
Protected Function GetAsyncCommand(ByVal commandMethodExpression As Expression(Of Func(Of Task))) As IAsyncCommand
...
End Function
End Class
End Namespace
How to Update Existing Apps
If you encounter a compilation error - "IDelegateCommand or IAsyncCommand could not be found", check that you referenced the DevExpress.Mvvm namespace in the files where this error occurs:
C#using DevExpress.Mvvm;
Visual BasicImports DevExpress.Mvvm