I have a property changed callback and in it i need to perform some validation.
I am going to take a new value and validate it against a set of other property criteria such as min and max values.
To do this I am planning to either take the dependency object from the changed event and use
DependencyObject.SetValue(TargetProperty,NewValue);
or cast it to a variable and use the properties directly
ObjectType myObjectType = (ObjectType)DependencyObject;
myObjectType.Target=NewValue;
My question is what would be the reasons for using either method over the other. Would casting be more of a drain on resources than say lots of SetValue/GetValue lookups etc? I will be referencing properties up to 10 times in the methods.
Many thanks.