Difference between Attached and non-Attached Dependency Properties in Silverlight

后端 未结 5 1315
心在旅途
心在旅途 2020-12-17 17:09

Okay Stackers, I\'ve spent a good couple of hours on this question, and I want to know if anybody has a definitive answer.
For all the research I\'ve done, I can\'t fin

5条回答
  •  庸人自扰
    2020-12-17 17:37

    They might not be much different as far as implementation is concerned but they are difference in actions i.e. they are different in what they do and are used for.

    Simple Register is used for simple dependency properties which you usually are used for bindings and validations so they are normal CLR properties with some additional magic which helps in WPF

    RegisterAttached is normally used where you want to expose a property that can be accessed and set in the child class like DockPanel where children of control tells parent where they want to be placed using Dock.Left or Dock.Right. So they are kind of special dependency properties which can be accessed in the child controls (which is not the case with simple Register properties) and they(in case of DockPanel) helps parent control in displaying children

    In short one cay say Register is used registering dependency properties which are used in same class while RegisterAttached is used for registering special dependency properties called attached properties and they are used and accessed by classes other than one which defined it

    This is a good explanation of Attached Properties and what cannot be achieved through simple DP

提交回复
热议问题