WPF: Revert textbox binding to default behaviour after validation errors
I have a textbox bound to a property开发者_Go百科 in my presentationlayer where string.empty is a non-valid value. When first entering and leaving keyboardfocus on this textbox I get not validationerrors which is desired. But if I start entering a value and then erase it again and leave the texbox I get the error. Can I somehow revert the binding-validation-behaviour back to its initial default state after I have made changes to it? I have tried doing a UpdateTarget on previewlostfocus but its still trying validate the empty string... I just want to be able to revert the binding to default so I can leave the field empty and not get validation errors even though the rule demands it... when doing UpdateTarget and the source does not have a valid value yet I would like the binding to be reset and no validation error displayed
I found another way of doing it. Just by resetting the binding with SetBinding(GetBinding(...)). It seem to work.
精彩评论