gpt4 book ai didi

wpf - 在WPF MVVM中使用行为?

转载 作者:行者123 更新时间:2023-12-04 15:02:12 26 4
gpt4 key购买 nike

我是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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com