Back to Devexpress

EventToCommand.EventArgsConverter Property

wpf-devexpress-dot-mvvm-dot-ui-dot-eventtocommand-580ce074.md

latest5.0 KB
Original Source

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

NuGet Package : DevExpress.Wpf.Core

Declaration

csharp
public IEventArgsConverter EventArgsConverter { get; set; }
vb
Public Property EventArgsConverter As IEventArgsConverter

Property Value

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

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

csharp
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);
}
vb
Public Interface IEventArgsConverter
    Function Convert(sender As Object, args As Object) As Object
End Interface
Public MustInherit Class EventArgsConverterBase(Of TArgs)
    Implements IEventArgsConverter
    Protected Sub New()
    Protected MustOverride Function Convert(sender As Object, args As TArgs) As Object
End Class

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.

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.

wpf-lookupedit-process-new-values/CS/HowToCreateLookUpEdit/MainWindow.xaml#L43

xml
SourceName="lookUpEdit">
<dxmvvm:EventToCommand.EventArgsConverter>
    <local:ProductListValueConverter/>

wpf-scheduler-specify-custom-edit-and-recurrence-dialogs/CS/CustomMvvmFormWithRecurrenceExample/MainWindow.xaml#L46

xml
<dxmvvm:EventToCommand EventName="InitNewAppointment" Command="{Binding InitNewAppointmentCommand}">
    <dxmvvm:EventToCommand.EventArgsConverter>
        <local:NewAppointmentInitConverter/>

wpf-pivot-grid-obtain-underlying-data/CS/ObtainUnderlyingData/MainWindow.xaml#L55

xml
PassEventArgsToCommand="True">
<dxmvvm:EventToCommand.EventArgsConverter>
    <dxpg:EventArgsToCellInfoConverter />

See Also

PassEventArgsToCommand

EventToCommand Class

EventToCommand Members

DevExpress.Mvvm.UI Namespace