Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2387
Data binding to ValueConstraint's
posted

I know that it is not possible to data bind directly to a ValueContraint because it is an Attached Dependency Property, so I though I might look for a workaround.  What I have done is extended the editor and added my own property which does support data binding.  Then in the callback for that property, go in and add the ValueContraint that I want set:

private static void OnNumberRspParamChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
  NumberRspParam numberRspParam = e.NewValue as NumberRspParam;
  if (numberRspParam != null)
  {
    d.SetValue(ValueConstraint.MaxInclusiveProperty, numberRspParam.MaxValue);
    d.SetValue(ValueConstraint.MinInclusiveProperty, numberRspParam.MinValue);
  }
}

This doesn't seem to have any effect.  I am wondering if there is some way I can make it work.  The issue is I am doing a dynamic form system where these parameters are not known until runtime.

Sam

Parents
No Data
Reply
  • 54937
    Offline posted

    The reason is doesn't work is that you are setting the MaxInclusiveProperty on the control and not on the ValueConstraint of the control. Since you are not changing the value of the properties of the ValueConstraint it will have no effect on the control. So in your property change callback you could get the ValueConstraint for d and then set the Max|MinInclusive property on that.

Children