File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,19 +79,24 @@ protected override void OnValueChanged(T value)
7979 {
8080 if ( enableNotifyError )
8181 {
82+ // comes new value, require to clear error.
83+ var previouslyHasErrors = ( errors != null && errors . Count != 0 ) ;
84+ errors ? . Clear ( ) ;
85+
8286 if ( validationContext != null )
8387 {
8488 if ( errors == null )
8589 {
8690 errors = new List < ValidationResult > ( validationContext . ValidatorCount ) ;
8791 }
88- errors . Clear ( ) ;
8992
9093 if ( ! validationContext . TryValidateValue ( value , errors ) )
9194 {
9295 ErrorsChanged ? . Invoke ( this , ValueChangedEventArgs . DataErrorsChanged ) ;
93-
94- // set is completed(validation does not call before set) so continue call PropertyChanged
96+ }
97+ else if ( previouslyHasErrors )
98+ {
99+ ErrorsChanged ? . Invoke ( this , ValueChangedEventArgs . DataErrorsChanged ) ;
95100 }
96101 }
97102 else if ( validator != null )
@@ -101,13 +106,16 @@ protected override void OnValueChanged(T value)
101106 {
102107 OnReceiveError ( error ) ;
103108 }
109+ else if ( previouslyHasErrors )
110+ {
111+ ErrorsChanged ? . Invoke ( this , ValueChangedEventArgs . DataErrorsChanged ) ;
112+ }
104113 }
105114 else
106115 {
107- // comes new value, clear error
108- if ( errors != null && errors . Count != 0 )
116+ if ( previouslyHasErrors )
109117 {
110- errors . Clear ( ) ;
118+ // notify error was cleared.
111119 ErrorsChanged ? . Invoke ( this , ValueChangedEventArgs . DataErrorsChanged ) ;
112120 }
113121 }
You can’t perform that action at this time.
0 commit comments