wpf - 在WPF MVVM中使用行为?

标签 wpf mvvm

我是WPF MVVM的新手。有人清除WPF中MVVM应用程序中“行为”的用法吗?为什么即使在WPF MVVM中有Method Action ,我们也应该追求“行为”?

最佳答案

行为是您附加到元素上的东西,它指定应用程序应在何时响应。

Action 附加到行为,并定义触发行为时应用程序应执行的操作。

From this article:

At a glance, a behavior looks similar to an action: a self-contained unit of functionality. The main difference is that actions expect to be invoked, and when invoked, they will perform some operation. A behavior does not have the concept of invocation; instead, it acts more as an add-on to an object: optional functionality that can be attached to an object if desired. It may do certain things in response to stimulus from the environment, but there is no guarantee that the user can control what this stimulus is: it is up to the behavior author to determine what can and cannot be customized.



And from this article:

Behaviors let you encapsulate multiple related or dependent activities plus state in a single reusable unit.

关于wpf - 在WPF MVVM中使用行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10683504/

相关文章:

c# - 为最短路径优化由 WPF 中的单元格组成的网格

wpf - 引用资源字典的正确方法是什么?

用于标记化的 WPF 控件

wpf - 绑定(bind)内容模板

wpf - 可观察的集合可以作为ref参数传递吗?

wpf - XAML 嵌套 DataTemplate 数据绑定(bind)

c# - 以编程方式更改 ScrollViewer 中的滚动条宽度

wpf - 您如何导航复杂的可视化树以重新绑定(bind)现有元素?

silverlight - 在 MVVM Light CommandParameterValue 中转换

c# - 如何通过匹配字段或属性名称从不同的类复制数据