I am trying to create an array of textblocks. And I am trying to create a new event for each textblock that is created. I have no problem creating the array of text blocks however I am not sure how to create a "list" of events to go along with it. Here is the code I have so far.
List<TextBlock> myList = new List<TextBlock>();
int octr = 1;
public void createlabels()
{
TextBlock tb = new TextBlock();
tb.Width = 200;
tb.Height = 60;
tb.Text = "label";
Canvas.SetLeft(tb, octr + 100);
Canvas.SetTop(tb, octr + 100);
myList.Add(tb);
myList[octr].MouseLeftButtonDown += new MouseButtonEventHandler(mylist_mouseleftbuttondown);
octr++;
}
void mylist_mouseleftbuttondown(object sender, MouseButtonEventArgs e)
{
TextBlock tb = (TextBlock)sender;
tb.Text = "New label";
}