Loop through Xamarin Forms Behaviors from ViewModel

markmunizmarkmuniz USUniversity ✭✭

Hello, I'm looking to validate a page by checking if all of the Xamarin Behaviors attached to each control are valid. I currently have a property called IsValid on each behavior which gets set to true/false depending on what is entered into the Entry. I'm attaching the behaviors like so:

<Entry Placeholder="Name">
      <Entry.Behaviors>
        <behaviors:RequiredBehavior/>
        <behaviors:NameBehavior/>
      </Entry.Behaviors>
</Entry>

I'm also setting the BindingContext of this page to one of my ViewModels. What would be the best way to loop through these behaviors within my viewmodel to check if the page is valid? Or is there a better route to validating all fields before proceeding to another page?

Answers

Sign In or Register to comment.