c# - WPF - put the name of every textblock in an array -


i want know if it's possible let code scan every name of every textblock in xaml file , put array.

for example:

xaml:

<textblock x:name="textblock1" /> 

c#:

string[] textblocknames = new string[] { "textblock1", "2", ... }; 

i know how scan controls type, has been explained here: find controls in wpf window type. don't know how find names , put in array.

i want use put borders around it, , similiar this:

        (int = 0; < 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 me this?

thanks in advance!

you can search texblocks in way: solution. can names every textblock in foreach loop like: tb.text, , put them array. can add border in way:

  (int = 0; < 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;             object item = gridname.findname(textblocknames[i]);             brd.child = item;         } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -