Binding Event to MVVM with EventArgs

5 posts, 0 answers
  1. John
    John avatar
    6 posts
    Member since:
    Mar 2015

    Posted 14 Sep 2017 Link to this post

    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>
  2. John
    John avatar
    6 posts
    Member since:
    Mar 2015

    Posted 14 Sep 2017 Link to this post

    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

     

  3. Paul
    Paul avatar
    3 posts
    Member since:
    Sep 2013

    Posted 11 Dec 2017 in reply to John Link to this post

    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

     

  4. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    457 posts

    Posted 14 Dec 2017 Link to this post

    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.
  5. Vladimir Stoyanov
    Admin
    Vladimir Stoyanov avatar
    457 posts

    Posted 15 Dec 2017 Link to this post

    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.
Back to Top