Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9064455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:15:23+00:00 2026-06-16T16:15:23+00:00

In my C# WPF windows Application I used Group Box with some labels and

  • 0
  • In my C# WPF windows Application I used Group Box with some labels and text boxes inside it to insert some data
  • I created a button called (add) beside one of text boxes in that Group Box
  • I want when I press (Add) button :
    • Group Box Expand in size and
    • a new Text Box appear below the first one to insert more data
    • (Add) button appear beside the new text box
  • I wish you could Help me ..Thanks

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:15:24+00:00Added an answer on June 16, 2026 at 4:15 pm

    See if this is what you are wanting, I used StackPanel's and a DockPanel which will grow as content is added, I also added the 5 extra TextBox's and TextBlock's with a visibility of collapsed which means that they do not take up any space when not visible. I added them to List’s which I then check visiblity when you click your button making the appropriate controls visible at that time.

    MainWindow.xaml

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="214" Width="525" SizeToContent="WidthAndHeight">
        <Grid>
            <GroupBox Header="General Information"   HorizontalAlignment="Left"  Name="groupBox1" VerticalAlignment="Top">
                <Grid >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="4*"/>
                        <ColumnDefinition Width="3*"/>
                    </Grid.ColumnDefinitions>
                    <DockPanel Grid.Column="0" HorizontalAlignment="Left" >
                       <Button VerticalAlignment="Bottom"  Height="25"   Click="Button_Click" >Add</Button>
                    </DockPanel>
                    <StackPanel Name="stackpanelTB" Grid.Column="1"  Orientation="Vertical"  >
                        <StackPanel.Resources>
                            <Style TargetType="{x:Type TextBox}">
                                <Setter Property="Margin" Value="0,4,0,0"/>
                            </Style>
                        </StackPanel.Resources>
                        <TextBox  Name="textBox1" Width="240" Height="25"></TextBox>
                        <TextBox Name="textBox2" Width="240" Height="25"></TextBox>
                        <TextBox Name="textBox3" Width="240" Height="25"></TextBox>
                        <TextBox Name="textBox4" Width="240" Height="25"></TextBox>
                        <TextBox Name="textBox5" Width="240" Visibility="Collapsed" Height="25"></TextBox>
                        <TextBox Name="textBox6" Width="240" Visibility="Collapsed" Height="25"></TextBox>
                        <TextBox Name="textBox7" Width="240" Visibility="Collapsed" Height="25"></TextBox>
                        <TextBox Name="textBox8" Width="240" Visibility="Collapsed" Height="25"></TextBox>
                        <TextBox Name="textBox9" Width="240" Visibility="Collapsed" Height="25"></TextBox>
                    </StackPanel>
                    <StackPanel Name ="stackpanelCaption" Grid.Column="2" Orientation="Vertical">
                        <StackPanel.Resources>
                            <Style TargetType="{x:Type TextBlock}">
                                <Setter Property="Margin" Value="0,4,0,0"/>
                            </Style>
                        </StackPanel.Resources>
                        <TextBlock Name="textBlock1" HorizontalAlignment="Right" Height="25">Ingredient ID</TextBlock>
                        <TextBlock Name="textBlock2" HorizontalAlignment="Right" Height="25">Ingredient Name</TextBlock>
                        <TextBlock Name="textBlock3" HorizontalAlignment="Right" Height="25">Chemical Str</TextBlock>
                        <TextBlock Name="textBlock4" HorizontalAlignment="Right" Height="25">Ingredient Salts</TextBlock>
                        <TextBlock Name="textBlock5" HorizontalAlignment="Right" Visibility="Collapsed" Height="25"></TextBlock>
                        <TextBlock Name="textBlock6" HorizontalAlignment="Right" Visibility="Collapsed" Height="25"></TextBlock>
                        <TextBlock Name="textBlock7" HorizontalAlignment="Right" Visibility="Collapsed" Height="25"></TextBlock>
                        <TextBlock Name="textBlock8" HorizontalAlignment="Right" Visibility="Collapsed" Height="25"></TextBlock>
                        <TextBlock Name="textBlock9" HorizontalAlignment="Right" Visibility="Collapsed" Height="25"></TextBlock>
                    </StackPanel>
                </Grid>
           </GroupBox>
        </Grid>
    </Window>
    

    MainWindow.xaml.cs

    using System;
    using System.Collections.Generic; 
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication1
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            List<TextBox> tboxList = new List<TextBox>();
            List<TextBlock> tblockList = new List<TextBlock>();
            public MainWindow()
            {
                InitializeComponent();
    
                tblockList.Add(textBlock1);
                tblockList.Add(textBlock2);
                tblockList.Add(textBlock3);
                tblockList.Add(textBlock4);
                tblockList.Add(textBlock5);
                tblockList.Add(textBlock6);
                tblockList.Add(textBlock7);
                tblockList.Add(textBlock8);
                tblockList.Add(textBlock9);
                tboxList.Add(textBox1);
                tboxList.Add(textBox2);
                tboxList.Add(textBox3);
                tboxList.Add(textBox4);
                tboxList.Add(textBox5);
                tboxList.Add(textBox6);
                tboxList.Add(textBox7);
                tboxList.Add(textBox8);
                tboxList.Add(textBox9);
            }
    
            private void Button_Click(object sender, RoutedEventArgs e)
            {
                for (int i = 0; i < 9; i++)
                {
                    if (tboxList[i].Visibility == Visibility.Collapsed)
                    {
                        tboxList[i].Visibility = Visibility.Visible;
                        tblockList[i].Visibility = Visibility.Visible;
                        break;
                    }
                }
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can both WPF and Windows forms controls be used within one application? How difficult
I used to work in windows and if in my C# wpf application I
I have a WPF Windows application. In one window there is a particular stackpanel
I have a fairly small solution that includes a WPF windows application. It builds
so this code here dynamically adds buttons to my wpf windows application. I cant
Hello I am creating a Windows application (WPF) that is going to be running
I am using ReportViewer to show the reports on my windows WPF application using
I want to use WPF windows in a legacy win32 application. I'd like to
We were testing our WPF application on Windows XP in the VMware Player (with
I have a WPF application with several windows. I would like to define GLOBAL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.