Display sfPopupLayout using just c#

Is it possible to display a sfPopupLayout using just c# (no XAML). Something like this:

public static class InputPopup
    {
        public static Task<string> ShowAsync()
        {
            var source = new TaskCompletionSource<string>();
 
            var popup = new SfPopupLayout();
            var entry = new Entry();
 
            entry.TextChanged += (s, e) =>
            {
                source.SetResult(e.NewTextValue);
            };
 
            popup.Content = entry;
            popup.Show();
            return source.Task;
        }
 
    }

...and then call it like this:
var input = await InputPopup.ShowAsync();



3 Replies

DS Divakar Subramaniam Syncfusion Team March 27, 2018 10:32 AM UTC

Hi Burton, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. Yes, you can display the popup by using just c# codes. Please refer the below code snippet, 
 
public class App : Application 
{ 
    internal static SfPopupLayout popupLayout; 
    public App() 
    { 
        popupLayout = new SfPopupLayout(); 
        var button = new Button(); 
        button.Clicked += Button_Clicked; 
        button.Text = "Click To Show Popup"; 
 
        var stackLayout = new StackLayout(); 
        stackLayout.Orientation = StackOrientation.Vertical; 
        stackLayout.Children.Add(button); 
 
        popupLayout.Content = stackLayout; 
        MainPage = new ContentPage() { Content = popupLayout }; 
    } 
 
    private void Button_Clicked(object sender, EventArgs e) 
    { 
        InputPopup.Show(); 
    } 
} 
 
public static class InputPopup 
{ 
    static Entry entry; 
    public static void Show() 
    { 
        entry = new Entry(); 
        entry.Text = "You can customize the popup!!!"; 
        entry.TextColor = Color.Black; 
        entry.TextChanged += Entry_TextChanged; 
 
        App.popupLayout.PopupView.ContentTemplate = new DataTemplate(() => { return entry; }); 
        App.popupLayout.Show(); 
    } 
 
    private static void Entry_TextChanged(object sender, TextChangedEventArgs e) 
    { 
 
    } 
} 
 
Also, we have prepared a simple sample in which the popup is displayed by using just c# codes and you can download the same from the below link, 
 
Please let us know if you need any other assistance. 
 
Regards, 
Divakar. 



EW Ewen January 19, 2021 01:57 AM UTC

Hi could you please provide sample for xamarin forms. android
Ewen


PK Pradeep Kumar Balakrishnan Syncfusion Team January 19, 2021 10:21 AM UTC

Hi Ewen, 
 
We have checked your requirement “How to create SfPopupLayout and its template in C# in xamarin forms android”. We have attached the sample for your requirement in the following link. 
 
Please refer the user guide documentation to know more about SfPopupLayout customization. 
 
Let us know if you any further assistance on this. 
 
Regards, 
Pradeep Kumar B 


Loader.
Up arrow icon