本文介绍了交互性.与附加属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试找出这些方法之间的一些差异.是否存在使用行为且附加属性无法完成相同功能的情况?
I'm trying to find some differences between these approaches. Is there any situation where behaviors are used and the same functionality could not be done with attached properties?
推荐答案
否.行为基本上只是附加属性之上的一种更好的抽象.
No. Behaviors are basically just a much nicer abstraction on top of attached properties.
通过使用 Behavior< T>
,您可以在运行时直接访问 AssociatedObject
,并具有轻松附加和分离行为的能力.
By using Behavior<T>
, you gain access to the AssociatedObject
directly, as well as the ability to attach and detach the behavior, easily, at runtime.
您可以使用附加属性来执行此操作,但是这将需要添加大量额外的管道.
You could do this with attached properties, but it would require adding a lot of extra plumbing.
这篇关于交互性.与附加属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!