Retrieving data from SFPopupLayout Xamarin.Forms

Hi all, I followed teh documentatoni on Xamarin.Forms and I'm trying to get data from a pop up, such as text or button click, what shoud I do please ?

1 Reply

SS Suhasini  Suresh Syncfusion Team April 5, 2018 12:13 PM UTC

Hi Damien, 
 
Thanks for contacting Syncfusion Support. 
 
You can get the button click notification, when the AcceptButton or DeclineButton in the footer is clicked, by setting the AcceptCommand and DeclineCommand.  
 
Please find the code snippet below to set the AcceptCommand and DeclineCommand for the SfPopupLayout. The CanExecute method of the AcceptCustomCommand will hit, when the AcceptButton is clicked and similarly CanExecute method of the DeclineCustomCommand will hit, when DeclineButton is clicked. 
 
//MainPage.xaml.cs 
popup = new SfPopupLayout(); 
popup.PopupView.AcceptCommand = new AcceptButtonCustomCommand(); 
popup.PopupView.DeclineCommand = new DeclineButtonCustomCommand(); 
 
//AcceptButtonCustomCommand.cs 
public class AcceptButtonCustomCommand : ICommand 
    { 
        public event EventHandler CanExecuteChanged; 
 
        public bool CanExecute(object parameter) 
        { 
            // Return true to close popup 
            return true; 
        } 
 
        public void Execute(object parameter) 
        { 
             
        } 
    } 
 
// DeclineButtonCustomCommand.cs 
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) 
        { 
 
        } 
    } 
 
 
You can get or set the text in the AcceptButton, DeclineButton and HeaderTitle by using the SfPopupLayout.PopupView.AcceptButtonText, SfPopupLayout.PopupView.DeclineButtonText and SfPopupLayout.PopupView.HeaderTitle  properties. 
 
Please find the code snippet for the same below: 
popup.PopupView.HeaderTitle = "Notification !!!"; 
popup.PopupView.AcceptButtonText = "Accept"; 
popup.PopupView.DeclineButtonText = "Decline"; 
 
You can set any template in the Popup. Please find the code snippet below in which the Label is loaded in the Popup. 
popup.PopupView.ContentTemplate = new DataTemplate(() => 
{ 
    Label label = new Label(); 
    label.BackgroundColor = Color.White; 
    label.Text = "Popup is displayed"; 
    return label; 
}); 
 
We have prepared a sample to achieve your requirement, you can download the same from the below link: 
 
Regards, 
Suhasini  
 
 


Loader.
Up arrow icon