I am pretty much new to Silverlight and hence after going through a dozen of articles on dependency properties I am still a bit confused about when do we need to explicitly create our own custom dependency properties? Those technical terms on those articles have confused me a lot. Can anyone explain me the scenario that when do we need to create our own DP when suppose using a textbox . If it is at all for binding only we could easily bind the text to something else in Viewmodel but why do we need a DP to be created on our own? I am bit confused. Please help me with an example.
As a rule of thumb: You should never need to create any DependencyProperties
in your ViewModels.
Explanation: You are using Controls
to compose your View from, those Controls need to have DependencyProperties because their values are filled through DataBindings
(a DataBinding would not be functioning when the corresponding property is no DP). But the source for that value does not need to be a DP (even if it is TwoWay binding). So your ViewModel can have ordinary Properties.
So only when you are at a point where you create your own custom Controls you will also need to define DependencyProperties inside these controls, otherwise you cannot use DataBinding.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments