title: ArgumentOutOfRangeException when calling VisualTreeHelper.GetChild()
body: <p>From time to time I'm running into an <strong><code>ArgumentOutOfRangeException</code></strong> when calling <code>VisualTreeHelper.GetChild()</code>.</p>
  <p>The exception mentions not to call that method when <code>VisualChildrenCount</code> equals 0 - which is what the <code>if</code> right before the call supposedly does.</p>
  <p>Am I missing something obvious here? I also tried to access <strong><code>contentPresenter.VisualChildrenCount</code></strong> but that property is protected.</p>
  <p><a href="https://i.stack.imgur.com/SBQpY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SBQpY.png" alt="Code with AregumentOutOfRangeException." /></a></p>