Answered by:
Dependency property validation or coercion in WinRT

-
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
- Edited by Aline Almeida Tuesday, February 11, 2014 4:27 PM
Tuesday, February 11, 2014 4:26 PM
Question
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
- Proposed as answer by Loganathan.v Wednesday, February 12, 2014 4:58 AM
- Marked as answer by Jamles HezModerator Monday, February 24, 2014 8:57 AM
Wednesday, February 12, 2014 12:04 AMOwner -
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
- Marked as answer by Jamles HezModerator Monday, February 24, 2014 8:57 AM
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
- Proposed as answer by Loganathan.v Wednesday, February 12, 2014 4:58 AM
- Marked as answer by Jamles HezModerator Monday, February 24, 2014 8:57 AM
Wednesday, February 12, 2014 12:04 AMOwner -
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
- Marked as answer by Jamles HezModerator Monday, February 24, 2014 8:57 AM
Monday, February 17, 2014 4:56 PM