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.
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.
Float Menu Item Working Navigation 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.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
The Code is given below.
Float Menu Item Working Navigation 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 FloatMenuItem
  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 >> Resourses >> Right Click >> drawable >> Add >> Existing Item.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Next, a dialogue box will open. Choose image location and add images.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Step 4
Next, add an image to Solution Explorer >> Project Name.Universal Windows Platform >>Right Click >> Add >> Existing Item.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Next, a dialogue box will open Choose image location and add images.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Step 5
The Image is added successfully for Android and UWP.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms Float Menu Item Working Navigation 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.
Float Menu Item Working Navigation 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.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Similarly, add the XAML page and give your name - "Page 2".
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Similarly, add the XAML page and give your name - "Page 3".
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Step 7
Open Solution Explorer >> Project Name >> Page1.xaml. Open the design view of this page.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
The Code is given below.
Float Menu Item Working Navigation 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="FloatMenuItem.Page1">
  5. <ContentPage.Content>
  6. <StackLayout>
  7. <Image Source="Android.png"/>
  8. </StackLayout>
  9. </ContentPage.Content>
  10. </ContentPage>
Step 8
Open Solution Explorer >> Project Name >> Page2.xaml. Open the design view of this Page.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
The Code is given below.
Float Menu Item Working Navigation 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="FloatMenuItem.Page2">
  5. <ContentPage.Content>
  6. <StackLayout>
  7. <Image Source="Windows.png"/>
  8. </StackLayout>
  9. </ContentPage.Content>
  10. </ContentPage>
Step 9
Open Solution Explorer >> Project Name >> Page3.xaml. Open the design view of this Page.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
The Code is given below.
Float Menu Item Working Navigation 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="FloatMenuItem.Page3">
  5. <ContentPage.Content>
  6. <StackLayout>
  7. <Image Source="Apple.jfif"/>
  8. </StackLayout>
  9. </ContentPage.Content>
  10. </ContentPage>
Step 10
Open Solution Explorer >> Project Name >> MainPage.xaml. Open the design view of this Page.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
The Code is given below.
Float Menu Item Working Navigation 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:FloatMenuItem"
  5. x:Class="FloatMenuItem.MainPage"
  6. BackgroundImage="CSharp.jpg">
  7. <AbsoluteLayout>
  8. <Grid AbsoluteLayout.LayoutBounds="1,1,-1,-1"
  9. AbsoluteLayout.LayoutFlags="PositionProportional"
  10. Margin="0,0,10,100">
  11. <Grid.RowDefinitions>
  12. <RowDefinition/>
  13. <RowDefinition/>
  14. <RowDefinition/>
  15. </Grid.RowDefinitions>
  16. <StackLayout Grid.Row="0" Orientation="Horizontal" IsVisible="False" x:Name="FloatMenuItem1">
  17. <Label Text="Android" VerticalOptions="Center"/>
  18. <Frame BackgroundColor="Red" CornerRadius="30">
  19. <Frame.GestureRecognizers>
  20. <TapGestureRecognizer x:Name="FloatMenuItem1Tap" Tapped="FloatMenuItem1Tap_OnTapped" />
  21. </Frame.GestureRecognizers>
  22. </Frame>
  23. </StackLayout>
  24. <StackLayout Grid.Row="1" Orientation="Horizontal" IsVisible="False" x:Name="FloatMenuItem2">
  25. <Label Text="Windows" VerticalOptions="Center"/>
  26. <Frame BackgroundColor="Green" CornerRadius="30">
  27. <Frame.GestureRecognizers>
  28. <TapGestureRecognizer x:Name="FloatMenuItem2Tap" Tapped="FloatMenuItem2Tap_OnTapped" />
  29. </Frame.GestureRecognizers>
  30. </Frame>
  31. </StackLayout>
  32. <StackLayout Grid.Row="2" Orientation="Horizontal" IsVisible="False" x:Name="FloatMenuItem3">
  33. <Label Text="iOS" VerticalOptions="Center"/>
  34. <Frame BackgroundColor="LightBlue" CornerRadius="30">
  35. <Frame.GestureRecognizers>
  36. <TapGestureRecognizer x:Name="FloatMenuItem3Tap" Tapped="FloatMenuItem3Tap_OnTapped" />
  37. </Frame.GestureRecognizers>
  38. </Frame>
  39. </StackLayout>
  40. </Grid>
  41. <Frame BackgroundColor="Blue" CornerRadius="30" HasShadow="True"
  42. AbsoluteLayout.LayoutFlags="PositionProportional"
  43. AbsoluteLayout.LayoutBounds="1,1,-1,-1"
  44. Margin="10">
  45. <Label Text="C#" TextColor="White" FontSize="Medium" FontAttributes="Bold"/>
  46. <Frame.GestureRecognizers>
  47. <TapGestureRecognizer Tapped="TapGestureRecognizer_OnTapped"/>
  48. </Frame.GestureRecognizers>
  49. </Frame>
  50. </AbsoluteLayout>
  51. </ContentPage>
Step 11
Open Solution Explorer >> Project Name >> MainPage.xaml.cs. Open the design view of this Page.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
The Code is given below.
Float Menu Item Working Navigation 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 FloatMenuItem
  8. {
  9. public partial class MainPage : ContentPage
  10. {
  11. public MainPage()
  12. {
  13. InitializeComponent();
  14. }
  15. private bool isOpen = false;
  16. private async void TapGestureRecognizer_OnTapped(object sender, EventArgs e)
  17. {
  18. if (isOpen == false)
  19. {
  20. isOpen = true;
  21. //Scale to smaller
  22. await ((Frame)sender).ScaleTo(0.8, 50, Easing.Linear);
  23. //Wait a moment
  24. await Task.Delay(100);
  25. //Scale to normal
  26. await ((Frame)sender).ScaleTo(1, 50, Easing.Linear);
  27. //Show FloatMenuItem1
  28. FloatMenuItem1.IsVisible = true;
  29. await FloatMenuItem1.TranslateTo(0, 0, 100);
  30. await FloatMenuItem1.TranslateTo(0, -20, 100);
  31. await FloatMenuItem1.TranslateTo(0, 0, 200);
  32. //Show FloatMenuItem2
  33. FloatMenuItem2.IsVisible = true;
  34. await FloatMenuItem2.TranslateTo(0, 0, 100);
  35. await FloatMenuItem2.TranslateTo(0, -20, 100);
  36. await FloatMenuItem2.TranslateTo(0, 0, 200);
  37. //Show FloatMenuItem3
  38. FloatMenuItem3.IsVisible = true;
  39. await FloatMenuItem3.TranslateTo(0, 0, 100);
  40. await FloatMenuItem3.TranslateTo(0, -20, 100);
  41. await FloatMenuItem3.TranslateTo(0, 0, 200);
  42. }
  43. else
  44. {
  45. isOpen = false;
  46. //Scale to smaller
  47. await ((Frame)sender).ScaleTo(0.8, 50, Easing.Linear);
  48. //Wait a moment
  49. await Task.Delay(100);
  50. //Scale to normal
  51. await ((Frame)sender).ScaleTo(1, 50, Easing.Linear);
  52. //Hide FloatMenuItem1
  53. await FloatMenuItem1.TranslateTo(0, 0, 100);
  54. await FloatMenuItem1.TranslateTo(0, -20, 100);
  55. await FloatMenuItem1.TranslateTo(0, 0, 200);
  56. FloatMenuItem1.IsVisible = false;
  57. //Hide FloatMenuItem2
  58. await FloatMenuItem2.TranslateTo(0, 0, 100);
  59. await FloatMenuItem2.TranslateTo(0, -20, 100);
  60. await FloatMenuItem2.TranslateTo(0, 0, 200);
  61. FloatMenuItem2.IsVisible = false;
  62. //Hide FloatMenuItem3
  63. await FloatMenuItem3.TranslateTo(0, 0, 100);
  64. await FloatMenuItem3.TranslateTo(0, -20, 100);
  65. await FloatMenuItem3.TranslateTo(0, 0, 200);
  66. FloatMenuItem3.IsVisible = false;
  67. }
  68. }
  69. private async void FloatMenuItem1Tap_OnTapped(object sender, EventArgs e)
  70. {
  71. await Navigation.PushAsync(new Page1());
  72. }
  73. private async void FloatMenuItem2Tap_OnTapped(object sender, EventArgs e)
  74. {
  75. await Navigation.PushAsync(new Page2());
  76. }
  77. private async void FloatMenuItem3Tap_OnTapped(object sender, EventArgs e)
  78. {
  79. await Navigation.PushAsync(new Page3());
  80. }
  81. }
  82. }
Step 12
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.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Click the "C#" Float item menu in Android, Windows, iOS.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Click Android Navigate and the Page 1 result is displayed.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms

Click Windows Navigate and the Page 2 result is displayed.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms

Click iOS Navigate the Page 3 result is displayed.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Windows Output
You can choose the UWP Platform.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Click the "C#" Float item menu in Android, Windows, iOS.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Click Android Navigate and the Page 1 result is displayed.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Click Windows Navigate and the Page 2 result is displayed.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Click iOS Navigate and the Page 3 result is displayed.
Float Menu Item Working Navigation In Android And UWP Using Xamarin.Forms
Finally, we have successfully created our desired Xamarin.Forms application.

Conclusion

I hope you have learned about Float Item Menu Working Navigation Android and UWP Using Xamarin.Forms with C#.