简体   繁体   English

与使用xamarin形式的视图的click事件相比,使用viewmodel命令有什么优势?

[英]what is the advantage of using viewmodel commands as compared to the view's click events in xamarin forms

I would like know the advantage of using commands in viewmodel in xamarin as compared to the click event handlers in the view class. 我想知道与在视图类中的click事件处理程序相比,在xamarin的viewmodel中使用命令的优势。 Click events seems simpler to use. 点击事件似乎更易于使用。 Please point out the pros and cons of both approches. 请指出两种方法的利弊。

Thanks 谢谢

Click events are tightly bound to your view and cannot be unit test. 点击事件与您的视图紧密相关,不能进行单元测试。 Using commands in view model makes the testing process very easy. 在视图模型中使用命令使测试过程非常容易。 This is a great view which will help clear thing up in detail. 这是一个很棒的视图,可以帮助您详细了解事情。 view models and unit testing 查看模型和单元测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM