Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Validating Xamarin Forms field behaviors quickly
using System;
using Xamarin.Forms;
namespace Behaviours
{
public class BehaviorValidatedInput<T> where T : InputView
{
public T Element { get; set; }
public bool IsValid
{
get {
foreach (var b in Element.Behaviors)
{
if (b is IValidatorBehavior && !((IValidatorBehavior)b).IsValid)
{
return false;
}
}
return true;
}
}
}
}
namespace Behaviours
{
public interface IValidatorBehavior
{
bool IsValid { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment