---
title: "How to add 5 dynamic TextBoxes in WPF and How to write Binding in c#"  
description: "How to add 5 dynamic TextBoxes in WPF and How to write Binding in c#"  
author: "kavya bathineni"  
published: 2016-11-18  
updated: 2016-11-18  
canonical: https://www.mindstick.com/forum/34206/how-to-add-5-dynamic-textboxes-in-wpf-and-how-to-write-binding-in-c-sharp  
category: "c#"  
tags: ["c#", "wpf"]  
reading_time: 2 minutes  

---

# How to add 5 dynamic TextBoxes in WPF and How to write Binding in c#

I am new to wpf .please help any one. i am adding only 5 textboxes for pick up locations but [database table](https://www.mindstick.com/forum/159366/how-to-test-regular-expressions-in-sql-without-using-database-table) name is same for all 5 textboxes. when i [click button](https://www.mindstick.com/forum/34274/how-to-pass-combobox-value-from-windows-form-edirrow-to-windows-form-form1-where-click-button) i am implement below [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) but it display unlimited i need only 5 textboxes.how to write condition.and in xmal we are write [binding](https://www.mindstick.com/blog/146/dynamic-binding-in-c-sharp) code <[TextBox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) Name="txtComments1" MaxLength="100" Width="213" Text="{Binding PurchaseOrder.Comments, Mode=TwoWay}" HorizontalAlignment="[Left](https://www.mindstick.com/articles/12768/don-t-be-left-behind-with-the-new-it-revolution)" 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;        }
```


---

Original Source: https://www.mindstick.com/forum/34206/how-to-add-5-dynamic-textboxes-in-wpf-and-how-to-write-binding-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
