I'm trying to replicate the email validator behavior in c# and, being the rookie that I am, have had trouble making sense of the XAML example to use in my c# page. I can't figure out how to bind an image to the isValid boolean behavior on my email entry. Has anyone done something similar already in c#?
My code currently looks like this:
var eEmail = new Entry
{
Text = selectedUser.email,
WidthRequest = 200,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand
//Behaviors.Add(new EmailValidationBehavior)
};
eEmail.Behaviors.Add(new EmailValidationBehavior());
var iInvalidEmail = new Image();
Here is the XAML example:
<local:BooleanToObjectConverter x:Key="boolToStyleImage"
x:TypeArguments="Style">
<local:BooleanToObjectConverter.FalseObject>
<Style TargetType="Image">
<Setter Property="HeightRequest" Value="20" />
<Setter Property="Source" Value="{local:ImageResource Samples.Images.error.png}" />
</Style>
</local:BooleanToObjectConverter.FalseObject>
<local:BooleanToObjectConverter x:Key="boolToStyleEmail"
x:TypeArguments="Style">
<local:BooleanToObjectConverter.FalseObject>
<Style TargetType="Label" BasedOn="{StaticResource baseStyle}">
<Setter Property="TextColor" Value="#F44336" />
<Setter Property="Text" Value="Enter a valid email" />
</Style>
</local:BooleanToObjectConverter.FalseObject>