Articles in this section
Category / Section

How to fire commands of the footer buttons in the SfPopup Layout

2 mins read

In SfPopupLayout for Xamarin.Forms you can handle the click of the accept and decline buttons in the footer area, by writing custom commands derived from ICommand. You can then perform any desired operation in the Execute override of your custom command.

 

Refer the following code example to write a custom command.

public class AcceptButtonCustomCommand : ICommand
{
    public event EventHandler CanExecuteChanged;
 
    public bool CanExecute(object parameter)
    {
        return true;
    }
 
    public void Execute(object parameter)
    {
        // Get the parent page of the PopupLayout to navigate to the next page
        ContentPage parentPage = ((parameter as SfPopupLayout).Parent as ContentPage);
        parentPage.Navigation.PushAsync(new SecondPage());    }
}
 
public class DeclineButtonCustomCommand : ICommand
{
    public event EventHandler CanExecuteChanged;
 
    public bool CanExecute(object parameter)
    {
        // Return true to close popup
        return true;
    }
 
    public void Execute(object parameter)
    {
 
    }
}

 

Assign the custom commands to the footer buttons as follows,

SfPopupLayout popup;
popup = new SfPopupLayout();
popup.PopupView.AcceptCommand = new AcceptButtonCustomCommand();
popup.PopupView.DeclineCommand = new DeclineButtonCustomCommand();

 

We have prepared a sample where we have loaded a popup in button click in the main page. Clicking on the accept button of the popup navigates to the next page and clicking on the decline button dismisses the popup.

We have internally fixed the issue “ Accept and Decline button commands not firing”, and the fix will be available from the 2018 Volume 1 Service Pack 1 release.
However use the assemblies from the below link until then to overcome the above mentioned issue.


Custom assemblies link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/Popup_dll672297334

The above assembly should replace the dll in the below mentioned location.            

  

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\pcl\Syncfusion.SfPopupLayout.XForms.dll     

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\android\Syncfusion. SfPopupLayout.XForms.dll    

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\android\Syncfusion. SfPopupLayout.XForms.Android.dll    

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\ios-unified\Syncfusion. SfPopupLayout.XForms.dll   

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\ios-unified\Syncfusion. SfPopupLayout.XForms.iOS.dll     

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\uwp\Syncfusion. SfPopupLayout.XForms.dll   

{Syncfusion Installed location}\Essential Studio\16.1.0.24 \Xamarin\lib\uwp\Syncfusion. SfPopupLayout.XForms.UWP.dll 

Disclaimer: Please note that we have created this assembly for the version 16.1.0.24 specifically to resolve the accept button and decline button commands not fired issue.

You can download the working sample with the necessary references added from the below link.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/SamplePopup481625673


 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied