Introduction

Xamarin is a platform that allows us to create a multi-platform app for Android, Windows, or iOS through a single integrated development environment (IDE). And with Xamarin.Forms, the interface design for all three platforms can be accomplished within its XAML-based standard, native user-interface control.
Email Verification In Android and UWP Using Xamarin.Forms
Android Output
Email Verification In Android and UWP Using Xamarin.Forms
Email Verification In Android and UWP Using Xamarin.Forms
UWP Output
Email Verification In Android and UWP Using Xamarin.Forms
Email Verification In Android and UWP Using Xamarin.Forms
Let's start.
Step 1
Open Visual Studio and go to New Project >> Installed >> Visual C# >> Cross-Platform.
Select the Cross-Platform app, then give your project a name and location.
Email Verification In Android and UWP Using Xamarin.Forms
Step 2
Open Solution Explorer >> Project Name (Portable) >> App.xaml.cs >> double-click will open the design view of this page.
Email Verification In Android and UWP Using Xamarin.Forms
The code is given below.
Email Verification In Android and UWP Using Xamarin.Forms
C# Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Xamarin.Forms;
  6. namespace Email_Verification
  7. {
  8. public partial class App : Application
  9. {
  10. public App()
  11. {
  12. InitializeComponent();
  13. MainPage = new NavigationPage(new MainPage());
  14. }
  15. protected override void OnStart()
  16. {
  17. // Handle when your app starts
  18. }
  19. protected override void OnSleep()
  20. {
  21. // Handle when your app sleeps
  22. }
  23. protected override void OnResume()
  24. {
  25. // Handle when your app resumes
  26. }
  27. }
  28. }
Step 3
Next, add an image to Solution Explorer >> Project Name.Android >> Resources >> Right-Click >> drawable >> Add > Existing Item.
Email Verification In Android and UWP Using Xamarin.Forms
Next, a dialogue box will open. Choose image location and add images.
Email Verification In Android and UWP Using Xamarin.Forms
Step 4
Next, add an image to the Solution Explorer. Go to Project Name.Universal Windows Platform >> Right-Click >> Add > Existing Item.
Email Verification In Android and UWP Using Xamarin.Forms
Next, a dialogue box will open. Choose image location and add images.
Email Verification In Android and UWP Using Xamarin.Forms
Step 5
The image is added successfully for Android and UWP.
Email Verification In Android and UWP Using Xamarin.Forms
Step 6
Next, open Solution Explorer >> project Name (Portable) >> Right-Click >> Add >> New Item or Ctrl+Shift+A.
Email Verification In Android and UWP Using Xamarin.Forms
A new dialogue box will open. Now, add the XAML page and give it a name. Click the "Add" button.
Email Verification In Android and UWP Using Xamarin.Forms
Step 7
Open Solution Explorer >> Project Name >> MainPage.xaml. Open the design view of this page.
Email Verification In Android and UWP Using Xamarin.Forms
The code for this is given below.
Email Verification In Android and UWP Using Xamarin.Forms
Xaml Code
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  4. xmlns:local="clr-namespace:Email_Verification"
  5. x:Class="Email_Verification.MainPage"
  6. BackgroundImage="Image.jpg">
  7. <ContentPage.Content>
  8. <StackLayout>
  9. <Button Text="Email Verification"
  10. Clicked="Button_Clicked"/>
  11. </StackLayout>
  12. </ContentPage.Content>
  13. </ContentPage>
Step 8
Open Solution Explorer >> Project Name >> MainPage.xaml.cs. Open the design view of this page.
Email Verification In Android and UWP Using Xamarin.Forms
The code is given below.
Email Verification In Android and UWP Using Xamarin.Forms
C# Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Xamarin.Forms;
  7. namespace Email_Verification
  8. {
  9. public partial class MainPage : ContentPage
  10. {
  11. public MainPage()
  12. {
  13. InitializeComponent();
  14. }
  15. async private void Button_Clicked(object sender, EventArgs e)
  16. {
  17. await Navigation.PushAsync(new Page1());
  18. }
  19. }
  20. }
Step 9
Open Solution Explorer >> Project Name >> Page1.xaml. Open the design view of this page.
Email Verification In Android and UWP Using Xamarin.Forms
The code is given below.
Email Verification In Android and UWP Using Xamarin.Forms
Xaml Code
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  4. x:Class="Email_Verification.Page1">
  5. <ContentPage.Content>
  6. <StackLayout VerticalOptions="Center" HorizontalOptions="Center">
  7. <Entry x:Name="EntryEmail" Placeholder="Enter The Email"/>
  8. <Label x:Name="LabelError" TextColor="Red"/>
  9. <Button Text="Validate" Clicked="Validar"/>
  10. </StackLayout>
  11. </ContentPage.Content>
  12. </ContentPage>
Step 10
Open Solution Explorer >> Project Name >> Page1.xaml.cs. Open the design view of this page.
Email Verification In Android and UWP Using Xamarin.Forms
The code is given below.
Email Verification In Android and UWP Using Xamarin.Forms
C# Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7. using Xamarin.Forms;
  8. using Xamarin.Forms.Xaml;
  9. namespace Email_Verification
  10. {
  11. [XamlCompilation(XamlCompilationOptions.Compile)]
  12. public partial class Page1 : ContentPage
  13. {
  14. public Page1()
  15. {
  16. InitializeComponent();
  17. }
  18. public void Validar(Object sender, EventArgs e)
  19. {
  20. var email = EntryEmail.Text;
  21. var emailPattern = "^([\\w\\.\\-]+)@([\\w\\-]+)((\\.(\\w){2,3})+)$";
  22. if (!String.IsNullOrWhiteSpace(email) && !(Regex.IsMatch(email, emailPattern)))
  23. {
  24. LabelError.Text = "EmailVerification Failed";
  25. }
  26. else
  27. {
  28. LabelError.Text = "Email Verification Success";
  29. }
  30. }
  31. }
  32. }
Step 11
Next, select the "Build and deploy" option followed by selecting from the list of Android Emulator or simulator. You can choose any API (Application program Interface) Level Emulator or simulator to run it.
Output
After a few seconds, you will see your app working.
Android Output
You can choose the Android Platform.
Email Verification In Android and UWP Using Xamarin.Forms
Enter the email and click the Validate button. The result is displayed.
Email Verification In Android and UWP Using Xamarin.Forms
Enter the Email and click the validate button. The result is displayed.
Email Verification In Android and UWP Using Xamarin.Forms
UWP Output
Similarly, you can choose UWP.
Email Verification In Android and UWP Using Xamarin.Forms
Enter the email and click the Validate button. The result is displayed.
Email Verification In Android and UWP Using Xamarin.Forms
Enter the email and click the Validate button. The result is displayed.
Email Verification In Android and UWP Using Xamarin.Forms
Finally, we have successfully created our desired Xamarin.Forms application.

Conclusion

I hope you have learned about email verification in Android and UWP using Xamarin.Forms with Visual Studio and C#.