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

Execute function on SfPopup button tapped

Thread ID:

Created:

Updated:

Platform:

Replies:

150947 Jan 25,2020 11:16 AM UTC Jan 27,2020 02:04 PM UTC Xamarin.Forms 1
loading
Tags: SfPopup
George
Asked On January 25, 2020 11:16 AM UTC

Hi,
I am using a SfPopup for confirmation.
When user is trying to delete an appontment a confirmation popup shows 
with a two botton footer.When User choose 'Yes' the CancelAppointment(string appointmentId) function should be executed 
to delete the appointment.

My cs file
...
 public AppointmentEditor()
        {
               .....
            InitializeComponent();
              ConfimDeletePopup.PopupView.AcceptCommand = new AcceptButtonCustomCommand();
            //ConfimDeletePopup.PopupView.DeclineCommand = new DeclineButtonCustomCommand();
             _appointment = appointment;
               ......
        }

private void OnDeleteClicked(object sender, EventArgs e)
        {
            ConfimDeletePopup.Show();
            //CancelAppointment(_appointment.Id.ToString());
        }
protected async void CancelAppointment(string appointmentId)
        {
         //Code for Cancel Appointment
         }

public class AcceptButtonCustomCommand : ICommand
        {
            public event EventHandler CanExecuteChanged;

            public bool CanExecute(object parameter)
            {
                return true;
            }

            public void Execute(object parameter)
            {
               //Here i need to execute CancelAppointment(string appointmentId) 
            }
            
        }
I can not figure out how to execute the CancelAppointment() function from the Execute method.
Thank you

Deepika Balasubramaniyan [Syncfusion]
Replied On January 27, 2020 02:04 PM UTC

Hi George,

Thankyou for contacting Syncfusion support.

We have checked your query “Execute function on SfPopup button tapped” and achieved your requirement by using AcceptCommand. We would like to inform you, in Execute method of AcceptButtonCustomCommand class, you can call your desired function. For further details you can refer following code example, and sample following here.

In the following sample, We have shown the another popup when click the Accept button of first popup.

Code Example:

[C#]

---

publicclassAcceptButtonCustomCommand : ICommand

{

publicevent EventHandler CanExecuteChanged;

SfPopupLayout secondPopup;

publicbool CanExecute(object parameter)

{

returntrue;

}

public void Execute(object parameter)

{

// You can write your set of codes that needs to be executed

CancelAppointment("Cancel");

}

protectedasyncvoid CancelAppointment(string appointmentId)

{

secondPopup = new SfPopupLayout();

secondPopup.PopupView.HeaderTitle = "CancelCodesWereExecuted";

secondPopup.Show(0,0);

//Code for Cancel Appointment

}

}

---

Sample link: https://www.syncfusion.com/downloads/support/forum/150947/ze/AcceptButtonCommand-1688829069.zip

Please let us know, if this helpful.

Regards,

Deepika.






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