title: Get all controls id of silverlight page
body: <p>I want to get all control's id of silverlight page.
  So I want to iterate through all controls inside xaml page.
  For this I have used following code:</p>
  
  <pre><code> private List&lt;UIElement&gt; GetElement(UIElement parent, Type targetType)
      {
          List&lt;UIElement&gt; items = new List&lt;UIElement&gt;();
          int count = VisualTreeHelper.GetChildrenCount(parent);
          if (count &gt; 0)
          {
              for (int i = 0; i &lt; count; i++)
              {
                  UIElement child = (UIElement)VisualTreeHelper.GetChild(parent, i);
                  if (child.GetType() == targetType)
                  {
                      items.Add(child);
                  }
              }
          }
          return items;
      }
  </code></pre>
  
  <p>and I call above function on my button click event as below.</p>
  
  <pre><code>    List&lt;UIElement&gt; lsttexts = GetElement(LayoutRoot, typeof(System.Windows.Controls.SLFramework.UniTextBox));
          List&lt;UIElement&gt; lstlabels = GetElement(LayoutRoot, typeof(TextBlock));
          List&lt;UIElement&gt; lstbtn = GetElement(LayoutRoot, typeof(Button));
          List&lt;UIElement&gt; lstcombo = GetElement(LayoutRoot, typeof(ComboBox));
          List&lt;UIElement&gt; lstStackpanel = GetElement(LayoutRoot, typeof(StackPanel));
  </code></pre>
  
  <p>Demo Example of my page:</p>
  
  <pre><code>  &lt;TextBlock Text="Name : " Grid.Row="0" Grid.Column="0"  HorizontalAlignment="Left" VerticalAlignment="Center" /&gt;
      &lt;StackPanel x:Name="stkpnl"  Grid.Row="0" Grid.Column="1" Orientation="Vertical"&gt;
          &lt;StackPanel x:Name="childpanel1" Orientation="Horizontal"&gt;
              &lt;TextBlock x:Name="lbl1" Text="Name : "  HorizontalAlignment="Left" VerticalAlignment="Center" /&gt;
              &lt;TextBox x:Name="txt1" Text="=test1"&gt;&lt;/TextBox&gt;
          &lt;/StackPanel&gt;
          &lt;StackPanel x:Name="childpanel11" Orientation="Horizontal"&gt;
              &lt;TextBlock x:Name="lbl11" Text="Name : "  HorizontalAlignment="Left" VerticalAlignment="Center" /&gt;
              &lt;TextBox x:Name="txt11" Text="=test11"&gt;&lt;/TextBox&gt;
          &lt;/StackPanel&gt;
      &lt;/StackPanel&gt;
  </code></pre>
  
  <p>It get all textbol and textbox outside the satckpanel, listitem and tab control.</p>
  
  <p>But I want to get all control of page includiing which are inside TabControl, statckpanel and Listitem. </p>
  
  <p>Thanks</p>