Skip to main content
All docs

IEventArgsTwoWayConverter Interface

Allows you to convert an event’s arguments to a command’s parameter and vice versa.

Namespace: DevExpress.Mvvm.UI

Assembly: DevExpress.Xpf.Core.v24.1.dll

NuGet Package: DevExpress.Wpf.Core


public interface IEventArgsTwoWayConverter :


Event Args Back Conversion

The EventToCommand behavior uses the EventArgsConverter property to pass event arguments to a command. If you need to take the arguments back from the command to the event, you can implement the IEventArgsTwoWayConverter in your converter class.

The IEventArgsTwoWayConverter extends the IEventArgsConverter interface and contains the ConvertBack method that is called after the command execution. This method accepts the performed command’s result as a parameter and allows you to pass this result to the event arguments.

You can inherit your converter class from the EventArgsConverterBase<TArgs> class that already implements the IEventArgsTwoWayConverter interface. Override the ConvertBack method and define the required logic.

The code sample below uses the back conversion to validate data:

<dxe:TextEdit EditValue="{Binding UserName}">
      <dxmvvm:EventToCommand Command="{Binding UserNameValidationCommand}"
public class ValidationArgs {
    public string ErrorContent { get; private set; }
    public object Value { get; }

    public ValidationArgs(object value) => Value = value;
    public void SetError(bool isValid, string errorContent) => ErrorContent = isValid ? null : errorContent;

public class ValidateEventArgsConverter : EventArgsConverterBase<ValidationEventArgs> {
    protected override object Convert(object sender, ValidationEventArgs e) => new ValidationArgs(e.Value);
    protected override void ConvertBack(object sender, ValidationEventArgs e, object parameter) {
        var args = parameter as ValidationArgs;
        e.IsValid = args.ErrorContent == null;
        e.ErrorContent = args.ErrorContent;


Two-way conversion requires the command to be executed immediately. You cannot use a Dispatcher that delays the command execution.

See Also