GuOrg/Gu.Wpf.NumericInput

Update validation errors

Closed this issue · 8 comments

WPF does not update validation errors if there already is an error.
Say we have < 5 rule and violate that with [6]
If we then type in [6abc] it should be updated to 'can't parse' but keeps the 'greater than' error.

Here is a screenie of vanilla TextBox:

screenie

Soved by dk.

Hi,
may I ask you how did you solved this issue?
I'm facing the same and another similar:

  • I have RequiredAttribute in VM
  • when I enter some invalid number [gg] I still get [field is required] error, I would expect [invalid number] error

(I'm using INotifyDataErrorInfo)

I don't remember the resolution but I think it was just me thinking about things the wrong way. Should have written something more useful when closing.

As for your issue it may be tricky as entering 'gg' does not send anything through the binding. What you can try is:

<numeric:DoubleBox CanValueBeNull="false"
                   ValidationTrigger="PropertyChanged"
                   ... />

CanValueBeNull should have been named IsRequiredsorry about that, setting it to false means the box cannot be empty.

ValidationTrigger controls when validation happens.

@ondrasvoboda did you get it to work?
We could potentially do something that would use attributes from the bound property, don't think it would be too hard, just not sure if it is a good fit for the library.
If we do it we should try to make the API so that it is somewhat clear what is going on. You can open an issue about it if you feel like it.

Have you seen gitter btw?

Unfortunately not.
I don't know how to mix validation errors from NumericInput with my validation in view model implementing INotifyDataErrorInfo.

Maybe there is a bug, we should try to put together a minimal repro. If you have time you can write a PR and add it as a window here

Then we can use it in UI-tests if you found a bug.

Alternatively create a repository with a minimal application showing the bug.

Join the gitter chat for faster discussions.

I think it is not a bug, it is by design.
One promising solution is here: https://stackoverflow.com/a/30070694 - I haven't tested yet. It requires no changes in NumericInput.

It works with INotifyDataErrorInfo, there are UI-tests for it. Not saying it works in your specific use case. You can clone the repo and check out the demo app.