---
title: "How to Find Child of Control in WPF"  
description: "Here in this blog you will find a method to get reference of child control inside a parent control. Through that method you can easily find child cont"  
author: "Anonymous User"  
published: 2011-05-05  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/155/how-to-find-child-of-control-in-wpf  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to Find Child of Control in WPF

Sonetime we want to get [reference](https://www.mindstick.com/forum/774/reference-what-does-this-error-mean-in-php) of [child control](https://www.mindstick.com/forum/249/finding-child-control-in-wpf) of [container](https://www.mindstick.com/forum/159610/how-to-connect-a-windows-container-to-a-service-running-on-localhost) control of specified type. Example we want to find [CheckBox control](https://www.mindstick.com/forum/379/checkbox-control-in-mvc) inside ListViewItem or we want to fing another container Panel inside a Grid.\

Here is a method through which we can find child [control inside](https://www.mindstick.com/forum/294/problem-in-access-the-control-inside-the-user-control) a [parent](https://www.mindstick.com/blog/154/how-to-find-parent-of-control-in-wpf) control. The method below will return the first [matching](https://www.mindstick.com/forum/162034/what-is-semantic-matching) control of the specified type (T), if control of specified type is not found in the provided parent control it will [return null](https://www.mindstick.com/forum/34356/facebook-email-field-return-null-even-if-the-email-permission-is-set-and-accepted).

```
/// <summary>/// Method to get child control of specified type/// </summary>/// <typeparam name="T">Type of child control queried</typeparam>/// <param name="parent">Reference of parent control in which child control resides</param>/// <returns>Returns reference of child control of specified type (T) if found, otherwise it will return null.</returns>private static T FindVisualChild<T>(DependencyObject parent) where T : DependencyObject{for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)       {              DependencyObject child = VisualTreeHelper.GetChild(parent, i);              if (child != null && child is T)                     return (T)child;else              {                     T childOfChild = FindVisualChild<T>(child);              if (childOfChild != null)                            return childOfChild;}}       return null;}
```

##### Hope you will find it helpful, if you have any doubt please feel free to ask.

---

Original Source: https://www.mindstick.com/blog/155/how-to-find-child-of-control-in-wpf

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
