开发者

Replacing an Event with a RelayCommand when Command property is not available in a third party control

I am using Devexpress's SpinEdit control on a view. There is an event on it called 'EditValueChanging'. I need to remove this event from the view's code-behind and use RelayCommand in viewmodel instead. However I don't find any Command propery in the control with which to bind the RelayCommand. Also I can't implement a dependency property in my viewmodel as I have already inherited it with Mvvmlight Toolkit's ViewModelBase (hence GetValue and SetValue are not available). What is the possible way to remove the logic present in EditValue开发者_Go百科Changing event in my view's code-behind and put it in my viewmodel?


Since you're already using MVVMLight, have you looked at its EventToCommand behavior?

Article from the author

Link to source for the class


You could try the code found in this link. It allows you to bind a VM's RelayCommand to any event, not just a button's command event. I use it all the time.


if you use MVVM Light anyway, just use the EventToCommand behavior. you can bind any event to an Command.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜