WPF C# adding event handler programmatically
问题 In my code I create an array of TextBoxes : namespace TCalc { public partial class MainWindow : Window { public TextBox[] pubAltArray; public MainWindow() { InitializeComponent(); pubAltArray = new TextBox[10]; Then I create the TextBoxes programmatically using the following code : private void generatePublishedTxtBox() { for (int i = 0; i < 10; i++) { TextBox pubAlt = new TextBox(); grid_profile.Children.Add(pubAlt); pubAlt.SetValue(Grid.RowProperty, 1); ... pubAltArray[i] = pubAlt; } } Than