Before I start to explain my problem: The Slider
is just an example for the following problem. I work on a custom control, that has to do a very similar thing like the slider does here:
Scenario:
- I have bound a
Slider.Value
to my ViewModel property calledMyValue
. - I have defined the
Maximum
of theSlider
to be100
. - Now I set the Property
MyValue
to200
.
What is the problem?
- The Slider will internally coerce the value to be 100.
- But the property
MyProperty
isn't being updated. - In my case (the custom control I built), I need to continue with the coersed value (100) later on, NOT the old (200) value.
Question:
Is there anything I can do in my custom control?
For example I tried myControl.GetExpression(MyValueProperty).UpdateSource();
in both my CoerseValueCallback
and PropertyChangedCallback
, but no matter what I try, the setter of the bound ViewModel-property is NEVER called and the property stays out of sync.