Data Annotation and MVVM Validation Behavior #1277
Replies: 2 comments 4 replies
-
Actually, I figured out how to already do this with a bunch of availble tools from this toolkit like EventToCommand. The downside is, there has to be an ObservableValidator for each property, but I can live with that for now..
This can be used in any viewmodel like this:
and then in XAML, like so
before publishing the model to backend from the viemodel an additional check can be performed like alreay for ObservableValidator with something like this
|
Beta Was this translation helpful? Give feedback.
-
This seems out of place for the MAUI Community Toolkit. The MVVM Source Generators are part of the .NET Community Toolkit. |
Beta Was this translation helpful? Give feedback.
-
I think it would be really great if Data Annotation and validation could be combined. While validation in the ViewModel is backed with ObservableValidator, validation inside the View works also great with the Behaviors.
If I am not missing aynthing, there still needs to be a lot of code written or when using the UI to validate but the backend changes, errors could occur quite easily. It would be wonderful, if an annotation like this:
would be enough and would create some bindable properties like a list of errors (string).
Beta Was this translation helpful? Give feedback.
All reactions