I am getting \"Value does not fall within the expected range exception\" when adding
children to stack panel. This happens even when myStackPanel.Children.Count = 0 just be
This error can be caused when there are two elements being added with the same name. In your case, are there any duplicate lDoc.Name values? If so, you could add an extra unique identifier. For example:
int id = 0; //outside foreach loop
myTextborder.Name = lDoc.Name + id.ToString();
id++;