This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Could the DisplayMemberBinding add support for ValidatesOnExceptions? It seems that it would require catching the exception and would be similar to handling the ValidateCell event and returning IsValid = false and ValidationMessage = Exception.Message. That would allow us to keep our validation logic in the property setters and we wouldn't have to explicitly handle the ValidateCell event in code-behind.
I don't have very many objects that have implemented IDataErrorInfo, but you may also want to look at implementing handling for that as well (ValidatesOnDataErrors). Thanks! |
|
|
Hello Jared This is a great idea. I'll look into this in the next 2 days. Jason Fauchelle |
|
|
Hello Jared The next nightly builds will include this automatic functionality of setting the validation state and tooltip when using ValidatesOnExceptions or ValidatesOnDataErrors when setting the DisplayMemberBinding. Jason Fauchelle |
|
|
Thanks Jason! I've downloaded it and it is close to what I was expecting. I do get the red border and the tooltip as expected. Great job! I am struggling with the behavior after that. In my properties I am performing some validation and throwing an exception prior to setting my value. See below to illustrate my point:
The problem that I am running into is that if I enter an invalid value, once I move off of that particular cell the value on the screen changes back to its previous value (as if the getter for the property gets called). This causes confusion to the user because now they have a red border & tooltip on a cell showing a different value than what they entered (and the value displayed is probably a valid value). See attached images. One other major issue that I have run into is the UpdateSourceTrigger on the Binding. I guess this isn't necessarily related to validation, but using DisplayMemberBinding with UpdateSourceTrigger set to LostFocus doesn't ever call my property setter. It seems to work well if the UpdateSourceTrigger is set to PropertyChanged, but more often than not with a TextBox edit control I will want the UpdateSourceTrigger to be LostFocus. Hopefully, this makes sense. Let me know if you have any questions. Thanks! You guys have been great to turn these issues around quickly. |
|
|
Hello Jared We will look into solving these issues next week. Jason Fauchelle |
|
|
Hello Jared Thanks for pointing out these issues. Both of these will be resolved in the next nightly build. Jason Fauchelle |
|
|
Thanks Jason! As always, good work! |
|