How to add 5 dynamic TextBoxes in WPF and How to write Binding in c#

Total Post:2

Points:14
C#  WPF 
C#
 1030  View(s)
Ratings:
Rate this:
I am new to wpf .please help any one. i am adding only 5 textboxes for pick up locations but database table name is same for all 5 textboxes. when i click button i am implement below code but it display unlimited i need only 5 textboxes.how to write condition.
and in xmal we are write binding code 
 <TextBox Name="txtComments1" MaxLength="100" Width="213" Text="{Binding PurchaseOrder.Comments, Mode=TwoWay}" HorizontalAlignment="Left" VerticalAlignment="Top" Canvas.Left="204" Canvas.Top="375" TabIndex="10" Height="39" MinHeight="15" />
How write in c# 
 private void button_Click(object sender, RoutedEventArgs e)
        {
           
                txtSource = new TextBox();
                txtSource.MinHeight = 15;
                txtSource.Width = 100;
                txtSource.Height = 25;
                txtSource.Name = "txtSource";
                txtSource.HorizontalAlignment = HorizontalAlignment.Left;
                Binding txtBinding = new Binding("PurchaseOrder.PickupSrcCodeName"); /*txtBinding.Mode = BindingMode.OneWay;*/
                txtSource.SetBinding(TextBox.TextProperty, txtBinding);
                ColumnDefinition colDef1;
                colDef1 = new ColumnDefinition();
                mymy.ColumnDefinitions.Add(colDef1);
                RowDefinition rowDef1;
                rowDef1 = new RowDefinition();
                mymy.RowDefinitions.Add(rowDef1);
                ++count;
           
            abc.Children.Add(txtSource);

            Grid.SetColumn(txtSource, count);
            Grid.SetRow(txtSource, 0);
            txtSource.GotFocus += t_GotFocus;
            //txtSource.TextChanged += this.t_TextChanged;
            txtSource.KeyDown += t_KeyDown;
        }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!