Skip to content

Instantly share code, notes, and snippets.

@ameerthehacker
Last active August 25, 2018 19:18
Show Gist options
  • Save ameerthehacker/436c295a2a91d4b4da0713f9b8f5cb12 to your computer and use it in GitHub Desktop.
Save ameerthehacker/436c295a2a91d4b4da0713f9b8f5cb12 to your computer and use it in GitHub Desktop.
...
namespace XamarinFormValidation.Behaviors
{
public class ValidationBehavior : Behavior<View>
{
...
public ValidationGroupBehavior Group { get; set; }
public bool Validate()
{
...
}
protected override void OnAttachedTo(BindableObject bindable)
{
...
if (Group != null)
{
Group.Add(this);
}
}
protected override void OnDetachingFrom(BindableObject bindable)
{
...
if (Group != null)
{
Group.Remove(this);
}
}
void OnUnFocused(object sender, FocusEventArgs e)
{
Validate();
if (Group != null)
{
Group.Update();
}
}
void OnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
...
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment