We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Button to start web API

Thread ID:

Created:

Updated:

Platform:

Replies:

146913 Aug 25,2019 10:41 PM UTC Aug 26,2019 09:03 AM UTC Xamarin.Forms 1
loading
Tags: SfButton
Prince
Asked On August 25, 2019 10:41 PM UTC

I'm trying to start a web API on button click but I have no idea how. I've already setup my button and the API has been added to the solution but I don't know how to call it with the button.

Muneesh Kumar G [Syncfusion]
Replied On August 26, 2019 09:03 AM UTC

Hi Prince, 
 
Greetings from Syncfusion, 
 
We can able to perform click action in SfButton in two ways.  
1.      Using Click event. 
2.      Using ICommand interface.  
 
Both the method will fire at the time of button tapped.  
 
 
[xaml] 
<StackLayout> 
            <buttons:SfButton  Text="Click Event" Clicked="SfButton_Clicked" HorizontalOptions="FillAndExpand" HeightRequest="40"/> 
            <buttons:SfButton  Text="ICommand" Command="{Binding ToggleCommand}" HorizontalOptions="FillAndExpand" HeightRequest="40"/> 
</StackLayout> 
 
[c#] 
  private void SfButton_Clicked(object sender, EventArgs e) 
        { 
            // Task to perform on button click 
        } 
 
//ViewModel 
. . .  
  public ICommand ToggleCommand { private set; get; } 
. . . 
 
  ToggleCommand = new Command( 
          execute: () => 
          { 
              Console.WriteLine("This is execute of ToggleCommand!"); 
          }, 
          canExecute: () => 
          { 
              return true; 
          }); 
. . . 
 
If your requirement is different from this, please revert us by modifying the below sample or provide more information. That will help us to provide solution earlier.  
 
 
Regards, 
Muneesh Kumar G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon