I want to know if it's possible to let my code scan every name of every textblock in my XAML file and put it into an array.
for example:
XAML:
<TextBlock x:Name="textBlock1" />
C#:
string[] textblocknames = new string[] { "textBlock1", "2", ... };
I know how to scan for controls by type, which has been explained here: Find all controls in WPF Window by type. But I don't know how to find the names and put it in an array.
I want to use this to put borders around it, and it would look similiar to this:
for (int i = 0; i < textblocknames.Length; i++)
{
Border brd = new Border();
brd.Name = string.Format("border_{0}", i);
brd.BorderThickness = new Thickness(0, 0, 1, 1);
brd.BorderBrush = Brushes.Black;
brd.Child = textblocknames[i]
}
Can someone help me with this?
Thanks in advance!