Introduction

Xamarin is a platform that allows us to create a multi-platform app for Android, Windows, and iOS through a single integrated development environment (IDE) with Xamarin.Form. The interface design for all three platforms can be accomplished within its XAML-based standard, native user-interfaces control.
Let's start.
Step 1
Open Visual Studio and go to New Project >> Installed>> Visual C# >> Cross-Platform.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Select the Cross- Platform app, then give your project a name and location.
Step 2
Open Solution Eplorerer >> Project Name (Portable) >> App.xaml.cs >> double-click will open the design view of this page.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The code is given below.
Picker Working Arithmetic Operators Android 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 Picker
  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, open Solution Explorer >> Project Name (Portable) >>Right-Click >> Add >> New Item or Ctrl+Shift+A.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
A new dialogue box will open. Now, add the XAML Page and give it a name. Click the "Add" button.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Step 4
Open Solution Explorer >> Project Name >> MainPage.xaml. Open the design view of this page.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The code is given below.
Picker Working Arithmetic Operators Android 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:Picker"
  5. x:Class="Picker.MainPage">
  6. <ContentPage.Content>
  7. <StackLayout>
  8. <Button Text="Picker" Clicked="Button_Clicked"/>
  9. </StackLayout>
  10. </ContentPage.Content>
  11. </ContentPage>
Step 5
Open Solution Explorer >> Project Name >> MainPage.xaml.cs. Open the design view of this page.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The code is given below.
Picker Working Arithmetic Operators Android 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 Picker
  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 6
Open Solution Explorer >> Project Name >> Page1.xaml. Open the design view of this page.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The code is given below.
Picker Working Arithmetic Operators Android 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="Picker.Page1">
  5. <ContentPage.Content>
  6. <StackLayout Orientation="Vertical">
  7. <Entry Placeholder="Enter Number 1" x:Name="No1"/>
  8. <Entry Placeholder="Enter Number 2" x:Name="No2"/>
  9. <Label Text="Select Operation" FontSize="Medium"/>
  10. <Picker x:Name="Pk" SelectedIndexChanged="Pk_SelectedIndexChanged"/>
  11. <Label Text="------" x:Name="mylab"/>
  12. </StackLayout>
  13. </ContentPage.Content>
  14. </ContentPage>
Step 7
Open Solution Explorer >> Project Name >> Page.xaml.cs. Open the design view of this page.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The code is given below.
Picker Working Arithmetic Operators Android 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. using Xamarin.Forms.Xaml;
  8. namespace Picker
  9. {
  10. [XamlCompilation(XamlCompilationOptions.Compile)]
  11. public partial class Page1 : ContentPage
  12. {
  13. public Page1()
  14. {
  15. InitializeComponent();
  16. Pk.Items.Add("Addition");
  17. Pk.Items.Add("Subtraction");
  18. Pk.Items.Add("Multiplication");
  19. Pk.Items.Add("Divition");
  20. }
  21. private void Pk_SelectedIndexChanged(object sender, EventArgs e)
  22. {
  23. string op = Pk.SelectedItem.ToString();
  24. int n1 = Int32.Parse(No1.Text);
  25. int n2 = Int32.Parse(No2.Text);
  26. double res = 0;
  27. if (op == "Addition")
  28. res = n1 + n2;
  29. else if (op == "Subtraction")
  30. res = n1 - n2;
  31. else if (op == "Multiplication")
  32. res = n1 * n2;
  33. else if (op == "Divition")
  34. res = n1 / n2;
  35. mylab.Text = res + "";
  36. }
  37. }
  38. }
Step 8
Next, select the "Build and Deploy" option followed by selecting from the list Android emulator and 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.

Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms

Enter the number and select the operation.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Click Addition Operation.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Click "Subtraction" operation.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Click the "Multiplication" operation.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Click the "Division" operation.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Windows Output
Let us now choose the UWP Platform.

Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms

Enter the number and select the Addition operator. Show the picker and choose.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Choose the Addition operation. The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Choose the Subtraction operation. The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Choose the Multiplication operator. The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms
Choose the Division operation. The result is displayed below.
Picker Working Arithmetic Operators Android UWP Using Xamarin.Forms

Conclusion

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