2

I have a number of Grid elements in a WPF Grid. Each Grid is named as 'DocumentPage1', 'DocumentPage2','DocumentPage3', etc.

If I wish to edit 'DocumentPage' + An'int'Variable, what am I to do?

This does not work:

...
int PageToAccess = 2;
"DocumentPage" + PageToAccess.Height = 200; //This does not work
...
rene
  • 41,474
  • 78
  • 114
  • 152
Theo
  • 548
  • 2
  • 8
  • 19

1 Answers1

3

You can use FindName to get a object by its name.

...
int PageToAccess = 2;
((Control)FindName("DocumentPage" + PageToAccess)).Height = 200;
...
J3soon
  • 3,013
  • 2
  • 29
  • 49