title: Set focus on TextBox in UserControl
body: <p>In my program I have a user control that displays data on a window using a content presenter. I would like to simply set the cursor focus on a certain <code>textBox</code> in my window at startup. </p>
  
  <p>Usually I would do this through the code-behind of the window, like this: <code>textBox.Focus();</code></p>
  
  <p>However, the <code>textBox</code> is defined in the user control, and doesn't seem to work the same way. So far I have tried the same method as above in the user control's code-behind.</p>
  
  <p>Why doesn't this work? How do I set the focus if the <code>textBox</code> is defined in a user control? </p>
  
  <p>What I have tried....:</p>
  
  <p>User Control:</p>
  
  <pre><code>public UserControl()
  {
      InitializeComponent();
  
      FocusManager.SetFocusedElement(this, textBox);
  }
  </code></pre>
  
  <p>User Control:</p>
  
  <pre><code>public UserControl()
  {
      InitializeComponent();
  
      textBox.Focusable = true;
      Keyboard.Focus(textBox);
  }
  </code></pre>