3

Is there a more general concept or name for what WPF calls "dependency properties"? I imagine this is not a WPF-ism and in fact other libraries or frameworks have employed a similar approach? If so, what are these other instances and what are the similarities and differences compared to Microsoft's dependency properties?

I am at a junction where I'm considering adding "dependency properties" to my own type system and object model (unrelated to WPF), as the construction seems appropriate for my design requirements; however, I want to consider what others have created as well, not just WPF's particular implementation.

  • This would be easier to answer if we knew what Dependency Properties are. – Jörg W Mittag Jun 20 '13 at 1:15
  • @JörgWMittag, see msdn.microsoft.com/en-us/library/ms752914.aspx – Rocklan Jun 20 '13 at 1:58
  • 1
    DP's seem to be a uniquely WPF thing. As far as I could ever tell they are just a fancy way of saying "When you set this property, we raise an event". – Rocklan Jun 20 '13 at 2:00
  • @LachlanB Also note that DPs allow you to apply inherited styles(values) in a manner vaguely resembling CSS. Inheriting values via a DP system is one of the mechanisms I'm considering here. – DuckMaestro Jun 20 '13 at 4:18
  • What exactly are your "dependency properties design requirements" you want to put into your library? Do you only need events that informs code that something has changed? This feature for example is implemented in the dotnet DataSets/DataTables. – k3b Jun 21 '13 at 7:13
2

Dependency Properties are used whenever you need a binding mechanism, i.e. a way to reflect changes to a property onto another one.

This is very useful in XAML, where you can bind attributes in the markup (without using code) and let the DP mechanism handle that.

Since you are familiar with WPF, you already know that. But the additional step is that XAML can be used to represent different object models. Workflows, for example! Take a look at WF3 (the original Workflow Foundation framework, which shipped with .NET 3.0) to see how DP are used there, it shows you how they can work (rather well) outside of the WPF world.

NOTE: look specifically at WF3: as pointed out in the comments, WF4 is quite different (it uses InArguments and OutArguments to pass values between activities, and I have no idea how those are implemented under the cover). Also, note that WF3 is obsolete, it is only good to look at it for didactic purposes - which is what you are looking for, I suppose

  • 1
    Note about WF3 (WWF shipped with .NET Framework 3): it was largely outdated with the release of .NET Framework 4, where WF was changed a lot. When advising someone to take a look at WWF 3, it's preferable to warn at the same time that the technology is obsolete and that WF 4 has not much to do with its predecessors. – Arseni Mourzenko Jun 21 '13 at 6:35
  • @MainMa good point! Indeed, my advice was "look at WF3, it was something that used DP outside WPF". I'll edit the answer to add your warning – Lorenzo Dematté Jun 21 '13 at 6:44
0

I'm pretty sure dependency properties are unique for WPF (and derived frameworks like Silverlight and WinRT).

Before WPF, data binding was done mostly though specific interfaces and consumers. Eg. model implemented specific interface and UI control consumed this specific interface.

Also, I hate calling dependency property as "Data Binding". I more prefer calling it "property (or data) synchronization", because it is much precise description what the feature really does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.