Interactivity.Behavior vs attached properties

后端 未结 4 685
萌比男神i
萌比男神i 2021-01-30 17:41

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 propert

4条回答
  •  半阙折子戏
    2021-01-30 18:24

    No. Behaviors are basically just a much nicer abstraction on top of attached properties.

    By using Behavior, 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.

提交回复
热议问题