Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF find a control

Tags:

wpf

I created a grid in procedural code on my WPF page. Now I want to reference that grid.

Grid grid = (Grid)This.FindName("myGridName")

does not work. Ideas?

like image 773
ScottG Avatar asked Nov 05 '08 19:11

ScottG


1 Answers

When you create an element in code, you need to also call the RegisterName method to allow FindName to work.

like image 62
Ian Oakes Avatar answered Nov 05 '22 07:11

Ian Oakes