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 name is same for all 5 textboxes. when i click button i am implement below code but it display unlimited i need only 5 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();
                RowDefinition rowDef1;
                rowDef1 = new RowDefinition();

            Grid.SetColumn(txtSource, count);
            Grid.SetRow(txtSource, 0);
            txtSource.GotFocus += t_GotFocus;
            //txtSource.TextChanged += this.t_TextChanged;
            txtSource.KeyDown += t_KeyDown;
Last updated:11/18/2016 9:18:44 PM

0 Answers