Carlo
Carlo

Reputation: 25969

Cost of using dependency properties

Say I have a control that inherits from UserControl (hence one of its super classes is DependencyObject). It's very easy to solve a notification problem using a DependencyProperty, since INotifyPropertyChanged needs a little implementation, and the other option would be creating a method to modify the state of the control (like myControl.HideTextBox()). I guess there are several more options to solve this, but since the control already inherits from DependencyObject, a DependencyProperty seems to be the more obvious way, but it might not be the optimal.

Any thought?

Thanks!

Upvotes: 0

Views: 136

Answers (1)

Pavel Minaev
Pavel Minaev

Reputation: 101615

The real feature of dependency properties isn't that you get change notification for free (though that is there). The real feature is that only dependency properties can be targets of data binding. This is what you should consider first and foremost when deciding whether a property should be dependency or not.

For a control, almost all properties should be bindable, and thus dependency.

Upvotes: 4

Related Questions