I have two DPs that I update in a DefiningGeometry get:
protected override Geometry DefiningGeometry
{
get
{
StartSc = sc.Transform(Start);
EndSc = sc.Transform(End);
//Start and End are also dependencies properties.
...
}
}
I bind to StartSc and EndSc but the target never gets updated, it always stays the default value of 0. Start and End change, so that is not the issue, I am wondering if assignment in the DefiningGeometry get doesn’t have an effect on the properties. Does anyone see any obvious mistake?
Note: I had the same variables names which were hiding the DPs from a derived class, removing the hiding the above code worked, but the bellow answer works either way.
If you bind to DPs and you are in the control’s code you want to use
SetCurrentValue(not the CLR-wrappers (StartSc&EndSc) which useSetValue) because otherwise you overwrite the existing bindings with the concrete value.Also as i said, avoid doing things in getters, it is really hard to tell when and how often they get called.