Timeline for Using INotifyDataErrorInfo on reusable control
Current License: CC BY-SA 4.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 24, 2022 at 9:29 | comment | added | BionicCode | I thought you were only styling or theming the controls, but you are overriding their functionality too. I understood that you have added a custom clear text button. Since the functionality is hidden inside the library, I can't help you. This is a classic example why you should avoid 3rd party libraries and only use them if absolutely necessary. It's very easy to implement such a button. Maybe the library contains a less invasive style that only themes the button without changing its behavior, so that you can add the clear feature yourself (to give you full control about the behavior). | |
May 24, 2022 at 6:48 | comment | added | BionicCode | Would be interesting to see how you delete the Textbox using this button. | |
May 24, 2022 at 0:10 | comment | added | drazse | I have found what's causing the problem. When I delete the content of the text box with the 'x' on the right side of the text box, it won't show the validation error (even tho MarkInvalid fires). However, if I delete it using the keyboard it shows it correctly. Any idea why this is happening? I'm using mahapps for design but why is this causing a problem? | |
May 23, 2022 at 8:29 | comment | added | BionicCode | Sorry, but I can't reproduce your issue. You either missed a detail of your implementation or the issue is related to the library you are using. Implementing data validation is really very simple. You can implement the third example of this answer: How to add validation to view model properties or how to implement INotifyDataErrorInfo. It will give you attribute based validation. I assume this will fix your issues. | |
May 23, 2022 at 1:24 | comment | added | drazse | Unfortunately, it didn't help it. I used your second example as the first one didn't show the tooltip with the error message, only the highlight on the text box. And yes, MarkInvalid is called, the error message is there, but it's not showing. The exception is null for Required, but it's also null in the case of the other ones. I don't get why it works for those and why it doesn't for this one. | |
May 23, 2022 at 0:33 | comment | added | BionicCode | Which solution have you implemented, the validation error delegation? And does hasError returns true? Is MarkInvalid called? I think the Required attribute will raise an exception. Have you tried to set ValidatesOnException to true for the internal TextBox binding? I guess this will fix it. | |
May 23, 2022 at 0:18 | comment | added | drazse | Thank you for the detailed answer! It works, except for one little detail. When I delete the content of the TextBox, it should also raise an error as it's marked as required. When I debugged it, the validationError.ErrorContent is set correctly, saying "The FirstName field is required.", however, the error is not shown. How can I make it so that the validation error tooltip is shown as for the other validation errors? | |
May 23, 2022 at 0:14 | vote | accept | drazse | ||
May 22, 2022 at 21:35 | history | edited | BionicCode | CC BY-SA 4.0 |
added 118 characters in body
|
May 22, 2022 at 21:21 | history | edited | BionicCode | CC BY-SA 4.0 |
added 2216 characters in body
|
May 22, 2022 at 20:00 | history | edited | BionicCode | CC BY-SA 4.0 |
added 195 characters in body
|
May 22, 2022 at 19:33 | history | answered | BionicCode | CC BY-SA 4.0 |