事件绑定到命令 [英] Bind Events to Commands

查看:107
本文介绍了事件绑定到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不使用第三部分的DLL,是有可能CellEditEnding的事件绑定到我的命令?目前,我正在使用.NET 3.5,因为它告诉我,我不能添加一个EventTrigger来触发采集这已成为一个问题。

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!

推荐答案

不知道这是最好的解决办法,但是当我在这种情况下我我通常只是做这样的事情。

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);
}

这篇关于事件绑定到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆