Hi All.
I'm trying to validate email address in the text field
<xctk:WatermarkTextBox x:Name="EmailTextBox" Watermark="Email Address" VerticalContentAlignment="Center"
Grid.Column="1" Grid.Row="3" TabIndex="3" Height="30" TextChanged="EmailTextBox_TextChanged"
LostFocus="EmailTextBox_LostFocus" >
<Binding Path="EmailAddress" />
</xctk:WatermarkTextBox>
<TextBlock x:Name="errEmail" Text="" FontSize="10" Foreground="#FFFF0000" Margin="5" Grid.Column="1" Grid.Row="3"
VerticalAlignment="Top" TextAlignment="Right" />
On online I found that code
bool IsValidEmail(string email)
{
try {
var addr = new System.Net.Mail.MailAddress(email);
return addr.Address == email;
}
catch {
return false;
}
}
How to apply this code for LostFocus event method?
Thanks.