Search code examples
xamarin.formsxamarin.androidvisual-studio-2019

How to display two text boxes as pop up using DisplayPromptAsync method in xamarin?


When I use -

string result = await DisplayPromptAsync("Question 1", "What's your name?");

It shows only one textbox in the pop-up. But how to display two or more textboxes in the pop-up?

Any help would be greatly appreciated.


Solution

  • As IvanIčin said that you can use Rg.Plugins.Popup to create custom popup.

    Firstly, install Rg.Plugins.Popup bu nuget package..., then creating popup page

    <pages:PopupPage
    x:Class="FormsSample.popup.popup2"
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup">
    <pages:PopupPage.Content>
        <StackLayout
            Padding="20,0"
            BackgroundColor="CadetBlue"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="Center">
            <Label Text="Question 1" />
            <Label Text="this is one question!" />
            <Entry />
            <Entry />
            <Button
                x:Name="btnsub"
                Clicked="btnsub_Clicked"
                Text="subit" />
        </StackLayout>
    </pages:PopupPage.Content>
    
    </pages:PopupPage>
    
     public partial class popup2 : PopupPage
    {
        public popup2()
        {
            InitializeComponent();
        }
    
        private void btnsub_Clicked(object sender, EventArgs e)
        {
    
        }
    }
    

    To call this Popup Page from contentpage button.click event.

     private async void btnPopupButton_Clicked(object sender, EventArgs e)
        {
           
            await PopupNavigation.Instance.PushAsync(new popup2());
        }
    

    You can see the screenshot:

    enter image description here