How number of text field will be added depending on number of button click

SwagatikaSwagatika Member ✭✭

If i press once Button means one text field will be added.If i press twice means again new text field will be added.How can i do it any suggestion please?

Best Answer


  • SwagatikaSwagatika Member ✭✭

                        <Label Text="Expenditure Details" Font="15"/>
                        <Button Text="AddMoreField" FontSize="Small" HorizontalOptions="EndAndExpand" FontAttributes="Bold"  Clicked="Button_Clicked"/>
                    <StackLayout  x:Name="AddEntry" IsVisible="False" Padding="20,0,0,0" HorizontalOptions="FillAndExpand">
                            <Entry Placeholder="Field1Name" />
                            <Entry Placeholder="Field1Name"/>
  • SwagatikaSwagatika Member ✭✭
        private void Button_Clicked(object sender, EventArgs e)
            AddEntry.Children.Add(new Entry());
  • SwagatikaSwagatika Member ✭✭

    Desired output i am not getting.

  • JohnHardmanJohnHardman GBUniversity mod

    @Swagatika said:
    Desired output i am not getting.

    Are you seeing any Entry views at all? If not, set IsVisible to True on your StackLayout.

    Then, if your Button_Clicked method is being called (check this by putting a breakpoint in it), you might find that your StackLayout needs VerticalOptions to have "AndExpand", so StartAndExpand, FillAndExpand etc.

  • SwagatikaSwagatika Member ✭✭

    this is the sample .I want to design like this if i click on add More field button then new field will come.

Sign In or Register to comment.