1

In WPF some properties of controls are dependency properties, others are normal properties.

Eg TextBox.SelectedText is a normal property and not a dependency property. I use MVVM and it happens often to me that I want to bind to some property, but I cant, because it is a normal property.

Can someone explain to me, what logic stands behind the decision whether a property is normal or a dependency property.

Also, can I work around this and somehow bind to the normal properties as if they were dependency properties?

thumbmunkeys
  • 20,606
  • 8
  • 62
  • 110

2 Answers2

1

You can bind to normal properties, but if your property changes, your binding will not get notified. However, you can implement INotifyPropertyChanged in your classes and the binding will update your control automatically.

Holstebroe
  • 4,993
  • 4
  • 29
  • 45
  • but why do i get this error then: A 'Binding' cannot be set on the 'CaretIndex' property of type 'TextBox'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject. – thumbmunkeys Dec 14 '10 at 09:54
  • Thats because only a dependency property can be the target of a binding.A DependencyProperty is always a property of an object derived from the DependencyObject class. – biju Dec 14 '10 at 10:01