MVVM-Light =>将命令参数和EventArgs传递给Command

Thr*_*r3e 9 c# silverlight commandparameter mvvm-light eventtocommand

MVVM-Light Toolkit在Silverlight 5中使用,我试图找到一种方法在事件到命令行为中将Command Parameters AND 传递EventArgs给ViewModel.

我没有找到一个职位提示路过的EventArgs作为命令参数,但在我的情况,我想用EventArgsCommand Parameter无论是在视图模型.

有人可以帮忙吗?

Thr*_*r3e 11

解决了问题....如果有人想知道......

概念:我们只需要通过MVVM-Light Event将EventArgs传递给Command.在Command的事件中,有一个属性Source.我们可以将这个'Source'属性转换为生成此命令的对象.

示例:

我们在ViewModel构造函数中使用eventargs声明命令

FilterQuotationsCommand = new RelayCommand<GridViewFilteredEventArgs>(FilterQuotationsCommandExecute);
Run Code Online (Sandbox Code Playgroud)

我们在将其发送到发送控件后通过"Source"访问发件人.

private void FilterQuotationsCommandExecute(GridViewFilteredEventArgs e)
    {
        var grid = (RadGridView) e.Source; // we casted the Source to Grid
        var item = grid.SelectedItem;      // we can access grid's selected items
    }
Run Code Online (Sandbox Code Playgroud)