I want to apply some validation on the entry input, I went to the docs page of the [attached behaviors](https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/behaviors/attached) 

and did this:

```
public enum TextType { Email, Phone, }
    public static class Validator
    {
        public static readonly BindableProperty TextTypeProperty = BindableProperty.CreateAttached(
            "TextType", typeof(TextType), typeof(Validator), TextType.Email, propertyChanged: ValidateText);

        public static TextType GetTextType(BindableObject view)
        {
            return (TextType)view.GetValue(TextTypeProperty);
        }

        public static void SetTextType(BindableObject view, TextType textType)
        {
            view.SetValue(TextTypeProperty, textType);
        }
        private static void ValidateText(BindableObject bindable, object oldValue, object newValue)
        {
            var entry = bindable as Entry;
            entry.TextChanged += Entry_TextChanged;
        }

        private static void Entry_TextChanged(object sender, TextChangedEventArgs e)
        {
            var entry = sender as Entry;
            bool isValid = false;
            switch (GetTextType(sender as Entry))
            {
                case TextType.Email:
                    isValid = e.NewTextValue.Contains("@");
                    break;
                case TextType.Phone:
                    isValid = Regex.IsMatch(e.NewTextValue, @"^\d+$");
                    break;
                default:
                    break;
            }

            if (isValid)
                entry.TextColor = Color.Default;
            else
                entry.TextColor = Color.Red;
        }
    }

```

in XAML:

```
<Entry beh:Validator.TextType="Email" Placeholder="Validate Email"/>

```

but it doesn't work, the setter nor the `propertyChanged` call back are never called,

also what is the difference between this "Attached behavior" and the [attached property](https://learn.microsoft.com/en-us/xamarin/xamarin-forms/xaml/attached-properties), the two pages are pretty identical