Binding Event to MVVM with EventArgs

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

    Posted 14 Sep 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
    5 posts
    Member since:
    Mar 2015

    Posted 14 Sep 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

     

Back to Top