changement de candidat à l'investissement
This commit is contained in:
parent
8114c2409c
commit
be3087fff6
351 changed files with 359 additions and 497 deletions
|
|
@ -1,53 +0,0 @@
|
|||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace BookAStar.Behaviors
|
||||
{
|
||||
public class RegexValidatorBehavior : Behavior<Entry>
|
||||
{
|
||||
private string regexp = @"^([\d\w]+)$";
|
||||
// Creating BindableProperties with Limited write access: http://iosapi.xamarin.com/index.aspx?link=M%3AXamarin.Forms.BindableObject.SetValue(Xamarin.Forms.BindablePropertyKey%2CSystem.Object)
|
||||
|
||||
static readonly BindablePropertyKey IsValidPropertyKey = BindableProperty.CreateReadOnly("IsValid", typeof(bool), typeof(RegexValidatorBehavior), false);
|
||||
|
||||
public static readonly BindableProperty IsValidProperty = IsValidPropertyKey.BindableProperty;
|
||||
|
||||
public bool IsValid
|
||||
{
|
||||
get { return (bool)base.GetValue(IsValidProperty); }
|
||||
private set { base.SetValue(IsValidPropertyKey, value); }
|
||||
}
|
||||
|
||||
protected string Regexp
|
||||
{
|
||||
get
|
||||
{
|
||||
return regexp;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
regexp = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnAttachedTo(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged += HandleTextChanged;
|
||||
}
|
||||
|
||||
|
||||
void HandleTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
IsValid = (Regex.IsMatch(e.NewTextValue, regexp, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)));
|
||||
((Entry)sender).TextColor = IsValid ? Color.Default : Color.Red;
|
||||
}
|
||||
|
||||
protected override void OnDetachingFrom(Entry bindable)
|
||||
{
|
||||
bindable.TextChanged -= HandleTextChanged;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue