title: How to force a Silverlight container to expand/contract to the size of its child controls?
body: <p>I've got a root UserControl that is 300 high.</p>
  
  <p>Inside that I have a Border that I want to expand to the size of its own controls, so if I stack in more controls, it will expand -- less controls, it will contract.</p>
  
  <p>However when I set it to "Auto" it expands it out to the size of <em>its parent container</em> instead of the size of its <em>child controls</em>.</p>
  
  <p>How can I get Border to expand and contract to the size of its child controls, something like the functionality of an HTML table?</p>
  
  <pre><code>&lt;UserControl   x:Class="Second105.Page"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
      Width="400" Height="300"&gt;
      &lt;Grid x:Name="LayoutRoot" Background="White"&gt;
          &lt;Border 
              Background="Tan" 
              CornerRadius="10" 
              Padding="10"
              Width="300" 
              Height="Auto"&gt;
          &lt;StackPanel&gt;
                  &lt;TextBlock HorizontalAlignment="Center" Margin="0 0 0 5"&gt;Please select a &lt;Run FontStyle="Italic"&gt;week day&lt;/Run&gt;:&lt;/TextBlock&gt;
              &lt;basics:Calendar
                  Name="theCalendar" 
                  SelectedDatesChanged="Calendar_SelectedDatesChanged"/&gt;
              &lt;TextBlock
                  Name="theMessage"
                  Margin="0 10 0 0"
                  HorizontalAlignment="Center"
                  Text="..."/&gt;
          &lt;/StackPanel&gt;
          &lt;/Border&gt;
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>