实施和使用的ICommand接口,MVVM [英] Implementing and using the ICommand interface, MVVM

查看:265
本文介绍了实施和使用的ICommand接口,MVVM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我深深地爱上了MVVM模式似乎有很多问题,我不能(还)找出自己。

Although I deeply fell in love with the MVVM pattern there seem to be a lot of problems I cannot (yet) figure out for myself.

我不知道的IComamnd接口的方法的参数,有利于

I wonder what the parameters of the methods of the IComamnd interface are good for

例如。 无效执行(对象参数);

我配合我认为像这样的视图模型

I tie my view to the view model like this

<Button Command="{Binding SomeCommand}" ... />

参数永远是零。

任何提示的欢迎。

谢谢!

更新: 织补,一分钟后,我张贴了这个问题,我发现<一个答案href="http://stackoverflow.com/questions/335849/wpf-commandparameter-is-null-first-time-canexecute-is-called">Stackoverflow.显然,控制确实有一个CommandParameter属性。

Update: Darn, one minute after I posted this question I found the answer on Stackoverflow. Obviously controls do have a CommandParameter property.

推荐答案

您可以添加CommandParameter =来传递参数。通常你会在传递的结合,或者一个id这是绑定的一部分,所以这个命令知道什么记录的工作。

You can add CommandParameter="" to pass a parameter. Usually you'll pass in the binding, or an id that's part of the binding, so the command knows what record to work with.

这篇关于实施和使用的ICommand接口,MVVM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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