Why dependency properties?

前端 未结 2 664
名媛妹妹
名媛妹妹 2020-12-04 12:17

Why did Microsoft go the route of making dependency properties and dependency objects instead of using reflection and maybe attributes?

2条回答
  •  一向
    一向 (楼主)
    2020-12-04 12:49

    Dependency properties solve a different usage scenario than reflection and attributes would solve.

    Dependency properties provide a single, consistent API for doing things that standard properties cannot handle.

    • The allow classes to provide a large number of properties without overhead (since they're only created, statically, when used, not once per class). For
    • The dependency property system handles things like Attached Properties in a consistent manner as standard dependency properties.
    • Dependency properties provide a clean API for change tracking as well as validation.
    • Dependency properties provide property value inheritance.
    • Dependency properties provide great performance benefits when data bound.

提交回复
热议问题