title: How does WPF determine focus?
body: <p><strong>My quandary is this:</strong> how does [whatever code that fires off LostFocus event] determine that it no longer has focus when child elements of the content may not be hit test visible? </p>
  
  <hr>
  
  <p><strong>Semi-relevant backstory</strong></p>
  
  <p>I've recently started a project to improve upon <code>Popup</code>. It sometimes becomes <em>stuck</em> open when trying to bind <code>IsOpen</code> to <code>ToggleButton.IsChecked</code>. Naturally, I began with handling <code>GotFocus</code> and <code>LostFocus</code>, but these often never worked, and I couldn't reliably force it in code with <code>Focus()</code> ("<em>Attempts</em> to set focus to this element") if I needed to. </p>
  
  <p>In my adorner-based solution, my first inelegant approach is to capture global MouseDown events in Win32 and determine if the mouse coordinate is within the adorner bounds. However this simply falls apart when some of that content is intended to be <strong>not</strong> hit test visible. </p>