title: How to access controls in inside Control Template in a Custom control
body: <p>I am developing a WPF Custom Control </p>
  
  <pre><code>&lt;ResourceDictionary xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:MultiSelectComboBox"&gt;
      &lt;Style TargetType="{x:Type local:MultiSelectComboBox}"&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type local:MultiSelectComboBox}"&gt;
                      &lt;Border Background="{TemplateBinding Background}"
                              BorderBrush="{TemplateBinding BorderBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"&gt;
                          &lt;Grid&gt;
                              &lt;Grid.ColumnDefinitions&gt;
                                  &lt;ColumnDefinition Width="*" /&gt;
                                  &lt;ColumnDefinition Width="Auto"/&gt;
                              &lt;/Grid.ColumnDefinitions &gt;
                              &lt;telerik:RadComboBox x:Name="PART_ComboBox"
                                                   Grid.Column="0"
                                                   ItemsSource="{Binding ItemsSource,RelativeSource={RelativeSource TemplatedParent}}" &gt;
                                 &lt;telerik:RadComboBox.Template&gt;
                                      &lt;ControlTemplate&gt;
                                          &lt;TextBlock x:Name="PART_ComboText"/&gt; 
                                      &lt;/ControlTemplate&gt;
                                  &lt;/telerik:RadComboBox.Template&gt;
                                  &lt;telerik:RadComboBox.ItemTemplate&gt; 
                                      &lt;DataTemplate&gt;
                                          &lt;StackPanel Orientation="Horizontal"&gt;
                                              &lt;CheckBox x:Name="PART_ItemCheckBox"/&gt;
                                              &lt;TextBlock x:Name="PART_ItemText"/&gt;
                                          &lt;/StackPanel&gt;
                                      &lt;/DataTemplate&gt;
                                  &lt;/telerik:RadComboBox.ItemTemplate&gt;
                              &lt;/telerik:RadComboBox&gt;
                              &lt;CheckBox Grid.Column="1" x:Name="PART_SelectAllCheckBox" VerticalAlignment="Center" IsChecked="{TemplateBinding IsAllSelected}" /&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>I want to get access to PART_ComboText</p>
  
  <p>I can access controls define there using GetTempalteChild method</p>
  
  <pre><code>part_comboBox = GetTemplateChild("PART_ComboBox") as RadComboBox;
  </code></pre>
  
  <p>But I am unable to access controls inside Control Template. For an example 
   which is in Control template couldn't access that. I know we couldn't access control templates from code behind. </p>
  
  <p>I tried this method. It also does not work.</p>
  
  <pre><code>part_comboBox = GetTemplateChild("PART_ComboBox") as RadComboBox;
  var comboBoxTemplate = part_comboBox.Template;
  part_comboText = (TextBlock) comboBoxTemplate.FindName("PART_ComboText", part_comboBox);
  </code></pre>