简体   繁体   中英

display a list while clicking in imagebutton and consuming webservice xamarin

I want to display a list when i click in imagebutton, how can i do to consume a resful webservice while using DisplayActionSheet. this is the code in xaml:

                    <ImageButton Source="list.png" x:Name="listEntité" 
                      Clicked="listEntité_Clicked"/>

and in xaml.cs:

  private async void listEntité_Clicked(object sender, EventArgs e)
    {
     await DisplayActionSheet("entity", "ok");
    }

When you set the buttons for DisplayActionSheet, you could switch to do something for webservice when the Button is pressed.

private async void ImageButton_Clicked(object sender, EventArgs e)
    {           
        var action = await DisplayActionSheet("ActionSheet: Send to?", "Cancel", null, "Email", "Twitter", "Facebook");
        switch (action)
        {
            case "Email":

                // Do Something when 'Email' Button is pressed

                break;

            case "Twitter":

                // Do Something when 'Twitter' Button is pressed

                break;
            case "Facebook":

                // Do Something when 'Facebook' Button is pressed

                break;              
        }
    }

DisplayActionSheet: https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.page.displayactionsheet?view=xamarin-forms

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM