Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input Validation with INotifyDataErrorInfo #5

Open
thomasclaudiushuber opened this issue May 21, 2021 · 3 comments
Open

Input Validation with INotifyDataErrorInfo #5

thomasclaudiushuber opened this issue May 21, 2021 · 3 comments
Labels
feature proposal New feature or request

Comments

@thomasclaudiushuber
Copy link
Owner

MvvmGen should support an easy way to implement input validation with the INotifyDataErrorInfo interface.

  • A ValidationViewModelBase class is something that could make sense.
  • A partial method that users could implement to return validation errors would also be great.
  • Also check if there is an easy way to integrate this with common validation patterns, like Data Annotations and FluentValidation

Note: This issue might make sense when WinUI gets its input validation done: microsoft/microsoft-ui-xaml#179

@thomasclaudiushuber thomasclaudiushuber added the feature proposal New feature or request label May 21, 2021
@Daimonion1980
Copy link

+1 for this proposal

I am facing InputValidation right now in WPF when using mvvmgen and wondering about why this feature isn't part of mvvmgen.

But i also read your discussion on ms-ui-xaml post and understand why you are not implementing this feature before ms implement the framework for this in win ui.

In the meantime. Do you have a suggestion for inputValidation in WPF in 2022?

@thomasclaudiushuber
Copy link
Owner Author

Hey @Daimonion1980 ,

yes, exactly, WinUI is the reason it's not here yet, but seems that the WinUI team is not making much progress on this one.

The approach for WPF is to implement INotifyPropertyChanged for input validation.

With mvvmgen, you could create a ValidationViewModelBase class that inherits from MvvmGen's ViewModelBase class. Then you implement the INotifyPropertyChanged interface on ValidationViewModelBase and you inherit your ViewModels that require validation from that new ValidationViewModelBase. To do that, you usually override the OnPropertyChanged method and from there you call a Validate method to add or remove errors per property (that you have to store in a dictionary).

Maybe I should create a simple example for this.

@Daimonion1980
Copy link

Thank you for your input.

An Example would be great. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature proposal New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants