I am creating a TextBox
and a Button
dynamically using the following code:
Button btnClickMe = new Button();
btnClickMe.Content = \"Cli
Another method is to set the associated TextBox
as Button Tag
when instanciating them.
btnClickMe.Tag = txtNumber;
This way you can retrieve it back in event handler.
protected void ClickMeClick(object sender, RoutedEventArgs e)
{
Button btnClickMe = sender as Button;
if (btnClickMe != null)
{
TextBox txtNumber = btnClickMe.Tag as TextBox;
// ...
}
}