WPF 命令和事件有什么区别?

What is the difference between WPF Command and Event?(WPF 命令和事件有什么区别?)
本文介绍了WPF 命令和事件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WPF CommandEvent 有什么区别?

What is the difference between WPF Command and Event?

推荐答案

一般来说,您可以对事件执行几乎与使用命令相同的操作,只是处理用户交互的模式不同.

Generally speaking you can do almost the same with events as with commands, it is just a different pattern of handling user interaction.

Commands 允许您将命令处理程序的实现移动到业务层.命令结合了启用状态和执行,因此一切就绪.通过搜索 MVVM 模式了解更多信息.

Commands in WPF allow you to move the implementation of a command handler to the buisness layer. Commands combine Enable state and executation, so everything is in place. Reade more by searching for the MVVM pattern.

一开始,命令实现起来比较复杂,所以如果您的应用程序很小,您应该考虑只使用事件.

Commands are more complex to implement at first, so if your application is small you should consider just sticking to events.

这篇关于WPF 命令和事件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
quot;Overflowquot; compiler error with -9223372036854775808L(编译器错误-9223372036854775808L(Q;溢出Q))
Visual Studio 2010 ReportViewer Assembly References(Visual Studio 2010 ReportViewer程序集引用)
Weird behaviour when I open a reportviewer in WPF(在WPF中打开报表查看器时出现奇怪的行为)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)