AcceptCommand and DeclineCommand

Hi, can you please provide an example of using the PopupView.AcceptCommand and PopupView.DeclineCommand methods please. I cannot find an example within the sample apps that you have provided. I have set them to commands within my own program, but am failing to get the command actions to fire.

5 Replies

SK Suriya Kalidoss Syncfusion Team March 15, 2018 10:35 AM UTC

Hi Peter , 
  We have analyzed your query. We can use commands for both accept and decline buttons with the help of custom commands. Create custom commands for both Accept and Decline button like shown below. 
    popupLayout.PopupView.AppearanceMode = Syncfusion.XForms.PopupLayout.AppearanceMode.TwoButton;        
 
     popupLayout.PopupView.AcceptCommand = new AcceptButtonCustomCommand(); 
 
     popupLayout.PopupView.DeclineCommand = new DeclineButtonCustomCommand(); 
 
        //Accept Button Event handler 
        public class AcceptButtonCustomCommand : ICommand 
        { 
            public event EventHandler CanExecuteChanged; 
 
            public bool CanExecute(object parameter) 
            { 
                return true; 
            } 
 
            public void Execute(object parameter) 
            { 
                System.Diagnostics.Debug.WriteLine("Accept Command Fires"); 
            } 
        } 
        //Decline Button Event handler 
        public class DeclineButtonCustomCommand : ICommand 
        { 
            public event EventHandler CanExecuteChanged; 
 
            public bool CanExecute(object parameter) 
            { 
                return true; 
            } 
 
            public void Execute(object parameter) 
            { 
                System.Diagnostics.Debug.WriteLine("Decline Command Fires"); 
            } 
        } 
 
We have also attached a working sample for your reference which can be downloaded from the below link.  
 
 
Regards, 
Suriya 



PM Peter Mortley March 16, 2018 04:37 PM UTC

Hi Suriya, thank-you for your response. I have downloaded your sample, and run it on UWP, Android and iOS, On all platforms the code compiled and ran, but on none of the platforms could I see any debug output when either the accept or decline buttons were pressed. Neither were breakpoints hit within the 'Execute' methods of the commands. Probably the most common use-case here will be that either the popup will be opened modally from 'MainPage', and it is possible to detect whether accept or decline has been pressed, or that an event handler is created in 'MainPage' that can detect which button has been pressed, or that the command object itself is defined at the 'MainPage' or ViewModel for the 'MainPage'. The supplied project included Syncfusion.Xamarin.SfPopupLayout 16.1.0.24, and I also tested at 16.1.0.26 without success.


SS Suhasini  Suresh Syncfusion Team March 19, 2018 11:37 AM UTC

Hi Peter, 
 
We have checked your query and the we have fixed the issue “Execute methods of the commands is not firing” internally. The fix for this issue will be available in the upcoming 2018 Volume 1 Service Pack 1 release. We appreciate your patience until then.  
 
However, you can refer the below KB for a solution until our Service Pack release. Please be aware that the KB link will be active only till our next Service Pack release.  
 
Regards, 
Suhasini  



PM Peter Mortley March 19, 2018 01:57 PM UTC

Hi Suhasini, thank-you for replying and for the updated code. I have downloaded the solution that you provided, and tested in on UWP, iOS and Android, and can see that it works now. Is there a release date for the next service pack?



SS Suhasini  Suresh Syncfusion Team March 20, 2018 11:13 AM UTC

Hi Peter, 
 
Thanks for your update. 
 
2018 Volume 1 Service Pack – 1 release will roll out in the last week of March 2018. 
 
Regards, 
Suhasini  


Loader.
Up arrow icon