title: Why would 'this.ContentTemplate.FindName' throw an InvalidOperationException on its own template?
body: <p>Ok... this has me stumped.  I've overridden <code>OnContentTemplateChanged</code> in my <code>UserControl</code> subclass.  I'm checking that the value passed in for <code>newContentTemplate</code> does in fact equal <code>this.ContentTemplate</code> (it does) yet when I call this...</p>
  <pre><code>var textBox = this.ContentTemplate.FindName(&quot;EditTextBox&quot;, this);
  </code></pre>
  <p>...it throws the following exception...</p>
  <blockquote>
  <p>&quot;This operation is valid only on elements that have this template applied.&quot;</p>
  </blockquote>
  <p>Per a commenter in another related question, he said you're supposed to pass in the content presenter for the control, not the control itself, so I then tried this...</p>
  <pre><code>var cp = FindVisualChild&lt;ContentPresenter&gt;(this);
  
  var textBox = this.ContentTemplate.FindName(&quot;EditTextBox&quot;, cp);
  </code></pre>
  <p>...where <code>FindVisualChild</code> is just a helper function used in MSDN's example (see below) to find the associated content presenter.  While <code>cp</code> is found, it too throws the same error.  I'm stumped!!</p>
  <p>Here's the helper function for reference...</p>
  <pre><code>private TChildItem FindVisualChild&lt;TChildItem&gt;(DependencyObject obj)
  where TChildItem : DependencyObject {
  
      for(int i = 0 ; i &lt; VisualTreeHelper.GetChildrenCount(obj) ; i++) {
  
          var child = VisualTreeHelper.GetChild(obj, i);
  
          if(child is TChildItem typedChild) {
              return typedChild;
          }
          else {
              var childOfChild = FindVisualChild&lt;TChildItem&gt;(child);
              if(childOfChild != null)
                  return childOfChild;
          }
      }
  
      return null;
  }
  </code></pre>