Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i find a child control in a grid by name?
i have a grid and add some dinamic control in it

i want to find a control in my grid by name

how can do this?
Posted

You could use the GetVisualDescendants from the <code>System.Windows.Controls.Primitives</code> namespace.
<pre>
IEnumerable<type> o = ((DependencyObject)_myGrid).GetVisualDescendants().OfType<type>();

foreach(Type objChild in o)
{
if (objChild.Name == "name")
{
//Do something
}
}pre>


Here Type is the type of control you are looking for.
 
Share this answer
 
v2
i try it this error Occurred:

Error 1 'System.Windows.DependencyObject' does not contain a definition for 'GetVisualDescendants' and no extension method 'GetVisualDescendants' accepting a first argument of type 'System.Windows.DependencyObject' could be found (are you missing a using directive or an assembly reference?)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900