title: how to bind popup value to dynamically created textbox?
body: <p>i am creating a Button and a textbox dynamically one by one in grid. My requirement is, if i click the button, the popup will show. and if i select the values from popup, i need to bind the corresponding row's textbox. Fr example, if i click the 5th row's button, i need to bind the popup item value to the 5th rows textbox. i struck on binding values to corresponding row's textbox. this may be simple one but i am unable to done this. this is my code.,</p>
  
  <p>Xaml:</p>
  
  <pre><code>&lt;Button x:Name="btn_addnewrow" Content="Add" HorizontalAlignment="Left" Margin="50,40,0,0" VerticalAlignment="Top" Width="89" Height="31"    Click="btn_addnewrow_Click"/&gt;
       &lt;Popup Name="popup" IsOpen="False" Placement="Mouse" VerticalOffset="15" HorizontalOffset="0" Margin="124,122,107,65"&gt;
           &lt;Border BorderBrush="Black" BorderThickness="1" Background="Coral"&gt;
               &lt;StackPanel Orientation="Horizontal" Height="143"&gt;
                   &lt;ListView Margin="10,10,0,0" Name="ListView1" HorizontalAlignment="Left"
                    VerticalAlignment="Top" Width="194" Height="133" MouseDoubleClick="ListView1_MouseDoubleClick"&gt;
                      &lt;ListViewItem Content="Coffie"&gt;&lt;/ListViewItem&gt;
                      &lt;ListViewItem Content="Tea"&gt;&lt;/ListViewItem&gt;
                      &lt;ListViewItem Content="Orange Juice"&gt;&lt;/ListViewItem&gt;
                      &lt;ListViewItem Content="Milk"&gt;&lt;/ListViewItem&gt;
                      &lt;ListViewItem Content="Iced Tea"&gt;&lt;/ListViewItem&gt;
                      &lt;ListViewItem Content="Mango Shake"&gt;&lt;/ListViewItem&gt;
                  &lt;/ListView&gt;
  
              &lt;/StackPanel&gt;
          &lt;/Border&gt;
      &lt;/Popup&gt;
  </code></pre>
  
  <p>cs:</p>
  
  <pre><code>    public int count = 0;
      public Button btn1;
      public Button btn2;
      public TextBox txt1;
  
      private void btn_addnewrow_Click(object sender, RoutedEventArgs e)
      {
          //Creating Rows..
          RowDefinition row0 = new RowDefinition();
          row0.Height = new GridLength(40);
          grid1.RowDefinitions.Add(row0);
  
          //Creating columns..
          ColumnDefinition col0 = new ColumnDefinition();
          ColumnDefinition col1 = new ColumnDefinition();
          ColumnDefinition col2 = new ColumnDefinition();
  
          col0.Width = new GridLength(50);
          col1.Width = new GridLength(100);
          col2.Width = new GridLength(70);
  
  
          grid1.ColumnDefinitions.Add(col0);
          grid1.ColumnDefinitions.Add(col1);
          grid1.ColumnDefinitions.Add(col2);
  
          int i = count;
  
          ////1st Column button
          btn1 = new Button();
          btn1.Margin = new Thickness(10, 10, 0, 0);
          btn1.BorderThickness = new Thickness(0);
          Grid.SetRow(btn1, i);
          Grid.SetColumn(btn1, 0);
          btn1.Tag = btn1;
          btn1.Click += btnBindList_Click;
          grid1.Children.Add(btn1);         
  
          //2nd column Textbox 
          txt1 = new TextBox();
          txt1.Margin = new Thickness(10, 10, 0, 0);
          txt1.Name = "txt" + i;
          Grid.SetRow(txt1, i);
          Grid.SetColumn(txt1, 1);
          txt1.Tag = txt1;
          grid1.Children.Add(txt1);
  
          count++;
      }
  
      private void btnBindList_Click(object sender, RoutedEventArgs e)
      {
            ?
            ?
          popup.IsOpen = true;
      }
  
      private void ListView1_MouseDoubleClick(object sender, RoutedEventArgs e)
      {
          txt1.Text = (ListView1.SelectedItem as ListViewItem).Content.ToString();
          popup.IsOpen = false;
      }
  </code></pre>