title: How do I make a Silverlight popup with a TextBox fill its parent?
body: <p>I have a popup within a user control.  The popup uses a TextBox to show a textual preview of data produced by the control.</p>
  
  <p>How do I make the popup size itself to the user control it's inside of?  With code as shown below, I find that the text box is sized according to its content, and the popup is sized according to the textbox.</p>
  
  <p>It works fine if I use fixed sizes in my row and column definitions, but I would like to popup to resize itself to match the user control (which in turn matches the browser).</p>
  
  <pre><code>&lt;UserControl
    &lt;!-- usual stuff here --&gt;
  &gt;
  &lt;Grid&gt;
  
  &lt;!-- layout for the user control here --&gt;
  &lt;!-- and after that my popup: --&gt;
  &lt;Popup Name="MyPopup"&gt;
     &lt;Border BorderBrush="Black" BorderThickness="2" &gt;
        &lt;Grid&gt;
           &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="22"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="*"&gt;&lt;/RowDefinition&gt;
           &lt;/Grid.RowDefinitions&gt;
           &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="*"&gt;&lt;/ColumnDefinition&gt;
           &lt;/Grid.ColumnDefinitions&gt;
  
           &lt;TextBlock Grid.Row="0" Text="Preview:" Margin="5" &gt;&lt;/TextBlock&gt;
           &lt;TextBox 
                Grid.Row="1"
                Name="MyTextBox" 
                IsReadOnly="True"
                HorizontalScrollBarVisibility="Visible"
                VerticalScrollBarVisibility="Visible"
                TextWrapping="Wrap"
                Margin="5"
                &gt;
            &lt;/TextBox&gt;
        &lt;/Grid&gt;
    &lt;/Border&gt;
  &lt;/Popup&gt;
  
  &lt;/Grid&gt;&lt;/UserControl&gt;
  </code></pre>