This is a migrated thread and some comments may be shown as answers.

Binding Event to MVVM with EventArgs

4 Answers 1552 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 2
John asked on 14 Sep 2017, 04:15 PM

I'm trying to bind EditEnding to my ViewModel with a RadDataForm

I get a null object to my command method. I need to have access to the EditAction property of the EditEndedEventArgs but I'm getting nada. 

Here's my ViewModel info:

public ReservePartViewModel()
{
    EditEndingCommand = new Telerik.Windows.Controls.DelegateCommand(OnEditEnding);
}
 
public ICommand EditEndingCommand { get; set; }
 
private void OnEditEnding(object obj)
{
    if (obj is EditEndedEventArgs)
    {
        var args = obj as EditEndingEventArgs;
        //do stuff here?
    }
}

 

Here's my View info:

<telerik:RadDataForm CurrentItem="{Binding}" AutoEdit="True" CommandButtonsVisibility="Commit,Cancel">
    <telerik:EventToCommandBehavior.EventBindings>
        <telerik:EventBinding Command="{Binding EditEndingCommand}" EventName="EditEnding" />
    </telerik:EventToCommandBehavior.EventBindings>
</telerik:RadDataForm>

4 Answers, 1 is accepted

Sort by
0
John
Top achievements
Rank 2
answered on 14 Sep 2017, 04:21 PM

Found the answer on Stack Overflow

Needed this PassEventArgsToCommand="True":

<telerik:RadDataForm CurrentItem="{Binding}" AutoEdit="True" CommandButtonsVisibility="Commit,Cancel">
    <telerik:EventToCommandBehavior.EventBindings>
        <telerik:EventBinding Command="{Binding EditEndingCommand}" EventName="EditEnding" PassEventArgsToCommand="True" />
    </telerik:EventToCommandBehavior.EventBindings>
</telerik:RadDataForm>

 

https://stackoverflow.com/questions/28448319/how-to-pass-argument-to-the-method-present-in-event-trigger-wpf

 

0
Paul
Top achievements
Rank 1
answered on 11 Dec 2017, 04:22 PM

Does anyone know which version this PassEventArgsToCommand was introduced ??  We are forced to stay on version 2013 and we don't seem to have this option available to us in XAML ?

 

Cheers

Paul

 

0
Vladimir Stoyanov
Telerik team
answered on 14 Dec 2017, 02:50 PM
Hi John,

The PassEventArgsToCommand property was introduced in the Q1 version of 2014 of Telerik UI for WPF.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Vladimir Stoyanov
Telerik team
answered on 15 Dec 2017, 02:25 PM
Hello John,

The PassEventArgsToCommand property was actually introduced with the Q3 2013 SP1. I apologize for misleading you on that.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
DataForm
Asked by
John
Top achievements
Rank 2
Answers by
John
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or