title: WPF Dockpanel first child uses remaining space
body: <p>In a window I have there is a list of <code>DockPanel</code>s to specify a couple of files. Each DockPanel has a TextBox (for the path) and a button (to browse for a file).</p>
  
  <p>I've recreated a simple WPF page to demostrate the problem here:</p>
  
  <pre><code>&lt;Page
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Width="150"
      Height="22"&gt;
      &lt;DockPanel&gt;
          &lt;TextBox HorizontalAlignment="Stretch"/&gt; &lt;!-- path to file --&gt;
          &lt;Button Content="..." DockPanel.Dock="Right"/&gt; &lt;!-- button to browse for file --&gt;
      &lt;/DockPanel&gt;
  &lt;/Page&gt;
  </code></pre>
  
  <p>The problem is that I want the button to the right of the textbox, but that causes the textbox to be really small since the LastChild of the DockPanel is the button it uses up the remaining space. Ive tried to change this by shuffling them around and setting <code>LastChildFill="False"</code> but that only causes the button to be small again, not making the TextBox wide (even with <code>HorizontalAlignment="Stretch"</code>).</p>
  
  <p>The reason I want the controls in that order is I want the user to reach the TextBox before the Button when using <code>tab</code> to navigate in the window. I looked into setting <code>TabIndex</code> but it feels hacky, favorite features of WPF is that tabindex are in the order the conrols are defined in the XAML. Not to mention that I probably would have to manually set TabIndex on everything in the Window.</p>
  
  <p>To me, it seems that the setting of TextBox.HorizontalAlignment isn't respected. <strong>How can I make the first control use as much space as it can but still preserve tab order?</strong></p>