I have a custom control that has an entry among others, to this control I have put this property:
public static readonly BindableProperty EntryBehaviorsProperty = BindableProperty.Create (nameof (Behaviors), typeof (List <Behavior <Entry>>), typeof (List <Behavior <Entry>>), null, BindingMode.OneTime, propertyChanged: OnBehaviorChanged);
private static void OnBehaviorChanged (BindableObject bindable, object oldValue, object newValue)
{
var view = bindable as EntryBorder;
if (view.Behaviors! = null && view.Behaviors.Count> 0)
{
foreach (var item in view.Behaviors)
{
//x:name entry
view.entryBorder.Behaviors.Add (item);
}
}
}
public new IList <Behavior> Behaviors
{
get => (IList <Behavior>) GetValue (EntryBehaviorsProperty);
set => SetValue (EntryBehaviorsProperty, value);
}
<controls:EntryBorder Style="{StaticResource GeneralEntryClear}" HorizontalOptions="FillAndExpand"
Text="{Binding PersonCustomerRequest.PersonaCliente.Nombre}"
>
<controls:EntryBorder.Behaviors>
<xct:EmailValidationBehavior x:Name="hola" Flags="ValidateOnUnfocusing" />
</controls:EntryBorder.Behaviors>
</controls:EntryBorder>
<Label Text="Invalid email"
TextColor="Red"
FontSize="10"
IsVisible="{Binding IsNotValid, Source={x:Reference hola}}" />
this doesn't work for me