title: WPF How do I make a Border width expand to fill available space in a DockPanel
body: <p>I have a custom control <code>ButtonRow</code> which will end up going into a different control.</p>
  
  <p>It is very simple, it has one Border, on label and one button.</p>
  
  <p>I need to make it so that the border will extend its width to fill up to where the button is.
  This is not happening as you can see in the below image:</p>
  
  <p><img src="https://i.stack.imgur.com/W5u8p.png" alt="Control Preview"></p>
  
  <p>The XAML can be found below. I have tried fiddling about with the horizontal alignment of both he label and the border, but they will only ever re-size to fit the text content of the label.</p>
  
  <p>I know there are existing question with very similar problems and names, but none have needed to do quite the same thing or have helped me solve my problem.</p>
  
  <p>I have tried using a StackPanel in horizontal alignment but all it did was make the button go next to the border.</p>
  
  <p>How can I make the border expand to fill the available space?</p>
  
  <pre class="lang-xaml prettyprint-override"><code>&lt;Grid&gt;
      &lt;DockPanel Height="Auto" HorizontalAlignment="Stretch" Margin="0" Name="dockPanel1" VerticalAlignment="Top" Width="Auto"&gt;
          &lt;Border BorderBrush="#FFDADFE1" Background="#FFECF0F1" BorderThickness="1" Height="20" Name="bdrFilter" HorizontalAlignment="Stretch"&gt;
              &lt;Label Content="Filter..." FontStyle="Italic" Foreground="#FF6C7A89" Height="20" Name="lblFilter" Padding="5,0" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" /&gt;
          &lt;/Border&gt;
          &lt;Button Style="{StaticResource FlatButtonStyle}" Content="+" Height="20" HorizontalAlignment="Right" Name="btnAddFilter" VerticalAlignment="Top" Width="20" Foreground="#FF6C7A89" ForceCursor="True" BorderBrush="{x:Null}" /&gt;
      &lt;/DockPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>(The button style does not affect its alignment or any other relevant properties)</p>