Nerd in Training
Nerd in Training

Reputation: 2230

Bind Events to Commands

Without the use of third part DLLs, is it possible to bind the event of CellEditEnding to my command? Currently, I am using .NET 3.5, which has become an issue because it tells me that I cannot add an EventTrigger to the Trigger collection.

<i:Interaction.Triggers>
    <i:EventTrigger EventName="CellEditEnding">
        <i:InvokeCommandAction CommandName="EnterUserCountCommand" />
    </i:EventTrigger>
</i:Interaction.Triggers>

Any help would be greatly appreciated!

Upvotes: 3

Views: 1174

Answers (1)

Kevin DiTraglia
Kevin DiTraglia

Reputation: 26078

Not sure if this is the best solution, but when I'm in this situation I usually just do something like this.

private void CellEditEndingEvent(object sender, RoutedEventArgs e)
{
    var viewModel = (MyViewModel)DataContext;
    //Change params as needed
    if (viewModel.MyCommand.CanExecute(null))
        viewModel.MyCommand.Execute(null);
}

Upvotes: 1

Related Questions