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. Image for the cookie policy date

Button to start web API

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.

1 Reply

MK Muneesh Kumar G Syncfusion Team 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 


Loader.
Live Chat Icon For mobile
Up arrow icon