title: Xamarin Foms best behaviors and validation
body: <p>I need to know how can I access my viewmodel the IsValid property of these behaviors.</p>
  
  <p>I'd rather you tell me a more robust behavior, because they are made from scratch, I would like to make a more robust validation with some nuget package already advanced despite being new to Xamarin Forms. </p>
  
  <p>This is my behavior, but I can not access the property "IsValid" my viewmodel: </p>
  
  <pre><code>  public class MesesTrabalhadosValidatorBehavior : Behavior&lt;Entry&gt;
          {
              private static readonly BindablePropertyKey IsValidPropertyKey = BindableProperty.CreateReadOnly("IsValid", typeof(bool), typeof(MesesTrabalhadosValidatorBehavior), false);
  
              public static readonly BindableProperty IsValidProperty = IsValidPropertyKey.BindableProperty;
  
              public bool IsValid
              {
                  get { return (bool)base.GetValue(IsValidProperty); }
                  private set { base.SetValue(IsValidPropertyKey, value); }
              }
  
              private void bindable_TextChanged(object sender, TextChangedEventArgs e)
              {
                  double result;
                  double.TryParse(e.NewTextValue, out result);
                  IsValid = result &gt; 0;
  
                  ((Entry)sender).TextColor = IsValid ? Color.Green : Color.Red;
              }
  
              protected override void OnAttachedTo(Entry bindable)
              {
                  bindable.TextChanged += bindable_TextChanged;
              }
  
              protected override void OnDetachingFrom(Entry bindable)
              {
                  bindable.TextChanged -= bindable_TextChanged;
              }
          }
  </code></pre>
  
  <p>My view:</p>
  
  <pre><code>    &lt;Entry Placeholder="Mêses trabalhados" Text="{Binding MesesTrabalhados}" Keyboard="Numeric"&gt;
            &lt;Entry.Behaviors&gt;
              &lt;local:MesesTrabalhadosValidatorBehavior /&gt;
            &lt;/Entry.Behaviors&gt;
          &lt;/Entry&gt;
  
          &lt;Entry Placeholder="Último salário" Text="{Binding Salario}" Keyboard="Numeric"&gt;
            &lt;Entry.Behaviors&gt;
              &lt;local:SalarioValidatorBehavior /&gt;
            &lt;/Entry.Behaviors&gt;
          &lt;/Entry&gt;
  
      &lt;ContentView Padding="0,20,0,0"&gt;
        &lt;Button Text="Calcular" HorizontalOptions="Fill" IsEnabled="{Binding IsValid}" Command="{Binding CalcularFgtsCommand, Mode=TwoWay}"/&gt;
      &lt;/ContentView&gt;
  </code></pre>