Jeff
Jeff

Reputation: 36583

Attached DependencyProperty Accessors - Why?

The MSDN documentation says that you must define accessors for your custom attached DependencyProperties: http://msdn.microsoft.com/en-us/library/ms749011.aspx (the "The Get Accessor" and "The Set Accessor").

Why are the accessors necessary? When you have an instance (non attached) DependencyProperty, the WPF runtime justs calls SetValue and GetValue. Why doesn't it just do the same thing for attached DependencyProperties?

Upvotes: 0

Views: 96

Answers (1)

user572559
user572559

Reputation:

those calls can be easily emitted using actual DPs declaration - after all you ever expect in there is a single line in both get & set calls. I think it's a got to do with XAML consumers/Intellisense. Neither regular DPs nor attached ones can be consumed from XAML without wrapping, for which we use CLR properties with regular DPs and accessors with attached DPs.

Sounds like a design flow, specially considering the fact those wrappers get bypassed by XAML loader. But the whole thing works, which is the most important thing:)

Upvotes: 0

Related Questions