I don’t think we have anything to make that simpler right now. So you would have to check the IsValid of all the fields you want to check and then enable or disable that button
Hi Gerald, thank you for posting all xamarin videos. They are really helpful. But I am struggling with one thing here. How can I validate all the fields in a form from my viewmodel method? Suppose I have 20 fields in a form, I don't want to have 20 booleans in my viewmodel for that and then check true for all of them. Is there any easier way to do this?
Make a property, that is logical AND for all your IsValid boolean properties. And notify property change when any of them change. (This way when you add another IsValid tomorrow, you wont have to change it on all places in your source, and possibly forget one of them leading to a bug)
About MultiValidation i have 2 more behaviors added and they are not in the example, just don't want to make it more complex. About command i'm using MVVM pattern and trying to separate Visual-View from logic code - ViewModel but in this situatin it's same if i use Clicked event or Command. Thank you and u have all my support
@@jfversluis In 2 words - Following MVVM. I have another suggestion. I'm interest a lot about scanning image to PDF(maybe ussing IOS Api and Android camera API), generating PDF from images etc... Maybe u can make some mini serial about this !
thank you so much . you are the best in youtube . please question when i set camera option property in camera view to External i cant detect usb camera connected to mobile . in other application in google play i can detect camera . please for what us External property ?
Ah that’s a good one! I think the external, right now, is just for desktop platforms like UWP. Didn’t even know you could have external cameras on Android 😅 Thank you for the kind words!
Hi Gerald, can you please explain to me how this toolkit behaviour can be used to do form-level validation for all the fields when a user might click a button to move to the next page, from inside a ViewModel please?
Thanks @Gerald, The problem with the XCT validation is that if we have an MVVM pattern implemented, you want to forcevalidation on a command action, rather than a click event. And currently that is not possible. However, a quick workaround is: // Set this on the content page void Button_Clicked(System.Object sender, System.EventArgs e) { EmailValidator.ForceValidate(); PasswordRequiredValidator.ForceValidate(); } // then on the command of the viewmodel validate against the validation rules (again). I hope we can trigger the validations at some real user interactive actions.
You can Bind the ForceValidateCommand to a command in your viewmodel and on the click of the button call "the bound command".Execute(null) method. It will trigger the validation and there is no need for code behind workarounds.
I'd love to help you but I'm afraid I can't do that. Maybe this one will help? github.com/marcojak/MTAdmob I'll see if I can create a video about that plugin soon :)
@@jfversluis Ok cool! Thanks. Can we make an online session about this? Please I must finish a project for next month... My phone number is: +96170239810
@@philippedoumet6073 I understand. But as you might imagine I have a pretty full schedule too :) As mentioned: I can't, for several reasons, offer any consulting like this. I already prioritized the AdMob video which I hope will help you, there is nothing much else I can do, sorry.
Aren’t these behaviors will cause duplication of code? Well because I need also to do these validations on the business layer. It’s not really DRYish... There must be a better way to do this stuff.
If that is a requirement you have then you're probably better off writing your own behavior and share the validation logic for sure. I think there are libraries that allow you to share the validation logic some more. Ideally you could share it from the ASP.NET backend all the way to your front-end. Hopefully with .NET MAUI!
*stackoverflow.com/questions/66005951/xamarin-community-toolkit-inputvalidation-connect-with-button/66006437?noredirect=1#comment116713113_66006437* here is the post. Thank you so much for the help
Another great tutorial for another great feature of the Xamarin Toolkit! Thanks!
Yaaay thank you for watching!
Thank you for the video! I would like to know how to enable the button if several fields are validated?
I don’t think we have anything to make that simpler right now. So you would have to check the IsValid of all the fields you want to check and then enable or disable that button
Hi Gerald, thank you for posting all xamarin videos. They are really helpful. But I am struggling with one thing here. How can I validate all the fields in a form from my viewmodel method? Suppose I have 20 fields in a form, I don't want to have 20 booleans in my viewmodel for that and then check true for all of them. Is there any easier way to do this?
Make a property, that is logical AND for all your IsValid boolean properties. And notify property change when any of them change.
(This way when you add another IsValid tomorrow, you wont have to change it on all places in your source, and possibly forget one of them leading to a bug)
But how do you handle the user clicking the button directly after typing? If the entry doesn't lose focus the validation logic is not executed.
Gerald and Xamarin so amazing
Ha! Thank you so much! ☺️
About MultiValidation i have 2 more behaviors added and they are not in the example, just don't want to make it more complex. About command i'm using MVVM pattern and trying to separate Visual-View from logic code - ViewModel but in this situatin it's same if i use Clicked event or Command. Thank you and u have all my support
And thank you for your support! I'm not sure on what you mean by this message though, sorry about that.
@@jfversluis In 2 words - Following MVVM. I have another suggestion. I'm interest a lot about scanning image to PDF(maybe ussing IOS Api and Android camera API), generating PDF from images etc... Maybe u can make some mini serial about this !
thank you so much . you are the best in youtube . please question when i set camera option property in camera view to External i cant detect usb camera connected to mobile . in other application in google play i can detect camera . please for what us External property ?
Ah that’s a good one! I think the external, right now, is just for desktop platforms like UWP. Didn’t even know you could have external cameras on Android 😅
Thank you for the kind words!
@@jfversluis yes i use external canon with video capture card to make full hd live stream with zooming
Hi Gerald, can you please explain to me how this toolkit behaviour can be used to do form-level validation for all the fields when a user might click a button to move to the next page, from inside a ViewModel please?
I think we have a PR now that allows you to add validation groups which will make this easier :)
Great video Gerald !! One question... how to validate picker using this ? Thanks !!!
I think there is validators in there that take a DateTime value so use those!
Thanks @Gerald,
The problem with the XCT validation is that if we have an MVVM pattern implemented, you want to forcevalidation on a command action, rather than a click event. And currently that is not possible.
However, a quick workaround is:
// Set this on the content page
void Button_Clicked(System.Object sender, System.EventArgs e)
{
EmailValidator.ForceValidate();
PasswordRequiredValidator.ForceValidate();
}
// then on the command of the viewmodel validate against the validation rules (again).
I hope we can trigger the validations at some real user interactive actions.
You can Bind the ForceValidateCommand to a command in your viewmodel and on the click of the button call "the bound command".Execute(null) method. It will trigger the validation and there is no need for code behind workarounds.
Thanks for sharing Michel!
Hello Gerald, please can we make an online Xamarin forms session where you teach me how to include google admob to my app? Please I will pay for it.
I'd love to help you but I'm afraid I can't do that. Maybe this one will help? github.com/marcojak/MTAdmob
I'll see if I can create a video about that plugin soon :)
@@jfversluis ok thanks I'll try it. Do you know how to use firebase?
@@philippedoumet6073 I've got a sample ready based on that plugin I linked. Might be the video for Thursday!
@@jfversluis Ok cool! Thanks. Can we make an online session about this? Please I must finish a project for next month... My phone number is: +96170239810
@@philippedoumet6073 I understand. But as you might imagine I have a pretty full schedule too :)
As mentioned: I can't, for several reasons, offer any consulting like this. I already prioritized the AdMob video which I hope will help you, there is nothing much else I can do, sorry.
Aren’t these behaviors will cause duplication of code? Well because I need also to do these validations on the business layer. It’s not really DRYish... There must be a better way to do this stuff.
If that is a requirement you have then you're probably better off writing your own behavior and share the validation logic for sure. I think there are libraries that allow you to share the validation logic some more. Ideally you could share it from the ASP.NET backend all the way to your front-end. Hopefully with .NET MAUI!
Everything... just perfection
Thanks 😄
@@jfversluis you're welcome
Great video!)
You only say that because you’re in it 😜
@@jfversluis ahahha
....
noooo
*stackoverflow.com/questions/66005951/xamarin-community-toolkit-inputvalidation-connect-with-button/66006437?noredirect=1#comment116713113_66006437* here is the post. Thank you so much for the help
❤️❤️
😍