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

Execute function on SfPopup button tapped

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

1 Reply

DB Deepika Balasubramaniyan Syncfusion Team January 27, 2020 06:04 AM

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.






Loader.
Live Chat Icon For mobile
Up arrow icon