I have a dependency property on a control which is a custom class.
Now is there an event that gets raised BEFORE the value is being changed?
I know that OnPropertyChanged is raised after the property has already changed.
I need some event before so that I can cancel the changing….in order to preserve the state of the control.
I cannot set back the dependency property back to its old value as that will mean that I lose state in the control.
Thanks!
If its your
DependencyProperty, you can use the ValidateValueCallback to validate the incoming value and reject it, if its not as you desire.In the following example, only values greater than 0 will be accepted: