locked
Dependency property validation or coercion in WinRT

    Question

  • Hi!

    I'm building a custom control in c# and I need to validate a dependency property.

    I found out that ValidateValueCallback and CoerceValueCallback are not available win WinRT.

    Does anyone know how to overcome this ?

    Thanks,

    Aline


    Tuesday, February 11, 2014 4:26 PM

Answers

  • You can create a callback in your PropertyMetadata which will be called when the property changes and this can be leveraged by a validation system. See Property metadata for a custom dependency property

    You can search for solutions people have used for validating in Silverlight. The same concepts will apply here.

    --Rob

    Wednesday, February 12, 2014 12:04 AM
    Moderator
  • Hi Rob,

    Thank you for your answer, but I'd like to prevent value from being assigned and not have to reassign it.

    I've chosen to throw an exception back to the app using my control.

    Aline

    Monday, February 17, 2014 4:56 PM

All replies

  • You can create a callback in your PropertyMetadata which will be called when the property changes and this can be leveraged by a validation system. See Property metadata for a custom dependency property

    You can search for solutions people have used for validating in Silverlight. The same concepts will apply here.

    --Rob

    Wednesday, February 12, 2014 12:04 AM
    Moderator
  • Hi Rob,

    Thank you for your answer, but I'd like to prevent value from being assigned and not have to reassign it.

    I've chosen to throw an exception back to the app using my control.

    Aline

    Monday, February 17, 2014 4:56 PM