EventToCommand.EventArgsConverter Property
Gets or sets an object that converts the event’s argument to a command’s parameter. This is a dependency property.
Namespace: DevExpress.Mvvm.UI
Assembly: DevExpress.Xpf.Core.v24.1.dll
NuGet Package: DevExpress.Wpf.Core
Declaration
Property Value
Type | Description |
---|---|
IEventArgsConverter | An object that implements the IEventArgsConverter interface. |
Remarks
The EventToCommand behavior allows you to pass an event’s arguments to a command. If you want to maintain the clean MVVM pattern and convert the event’s arguments to an object suitable for the command, specify the EventArgsConverter property as follows:
<ListBox x:Name="list">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="MouseDoubleClick" Command="{Binding EditCommand}" EventArgsConverter="{dxmvvm:ItemsControlMouseEventArgsConverter}"/>
</dxmvvm:Interaction.Behaviors>
</ListBox>
The defined EventArgsConverter should implement the IEventArgsConverter interface. You can also derive the converter from the EventArgsConverterBase<TArgs> class, which already implements the IEventArgsConverter interface.
public interface IEventArgsConverter {
object Convert(object sender, object args);
}
public abstract class EventArgsConverterBase<TArgs> : IEventArgsConverter {
protected EventArgsConverterBase();
protected abstract object Convert(object sender, TArgs args);
}
A parameter that a command processes may indicate to the source object how to implement a certain action. You can pass the parameter from the command to the bound event, so that the source object can determine how to proceed. Create a converter class that implements IEventArgsTwoWayConverter and assign the class object to the EventArgsConverter property.
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the EventArgsConverter property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.