How to create Action sheets using Xamarin.Forms

Xamarin.Forms
img_xamarin

All mobile applications, no matter what they are about, they have one common and obvious characteristic: They offer interaction, which means that they are not static, but require input or actions needed to be taken by users from time to time in order to function properly.

Action sheets consist of a really convenient and fast way to display a bunch of options that the user should select from, and it is widely used in great number of applications.

  • First create a new solution and name it as “ActionSheetXamarinForm” .
    xf3.1
  • First of all we go to “ActionSheetXamarinForms.cs” and add the following code inside the constructor.
  • Above line of code will set “ActionSheetpage” as the main page and add a Navigation Bar to the main page.
  • Navigation Bar is neccessory to invoke “DisplayActionSheet” it will not work without adding it.
  • Create a new file and name it as
    xf3.2
  • Now add one label and two button inside the constructor the code for it is as follows
  • The above code will create one label and two buttons.
  • The main task is to create and display an actionsheet while the button is being clicked so we have to apply a click event on both the buttons add the following code to create a actionsheet in click event of the button.
  • Now that we have created the click events for the button. Its time to add the label and the button as the children of the “ActionSheetPage”

Now we have finished with the application run you app in both android and ios simulator and test them.
Simulator for android and iOS will look like below.

xf3.3

xf3.4

Android simulator will look like below

xf3.5

xf3.6

If you like this tutorial then you can download full copy of the code from github

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">