title: Restrict the Width of a ContentPresenter's to its Dynamic Content
body: <p>I would like to be able to dynamically adjust the size of a content control.</p>
  
  <p>Here's a simple example:</p>
  
  <pre><code>...
  &lt;Slider x:Name="width" Minimum="40" Value="100" Maximum="300"/&gt;
  ...
  &lt;ContentPresenter Width="{Binding Value, ElementName=width}" Content="Some value"&gt;
     &lt;ContentPresenter.ContentTemplate&gt;
        &lt;DataTemplate&gt;
           &lt;Grid MaxWidth="200" MinWidth="80"&gt;
              &lt;Rectangle Fill="Wheat" /&gt;
              &lt;TextBlock Text="{Binding}"/&gt;
           &lt;/Grid&gt;
        &lt;/DataTemplate&gt;
     &lt;/ContentPresenter.ContentTemplate&gt;
  &lt;/ContentPresenter&gt;
  </code></pre>
  
  <p>Given this example, I would like to force the width of the content ContentPresenter to stay within the min and max width of its generated child (80 - 200 in this case). </p>
  
  <p>Obviously with a simple example like this I could just change the range of the slider, but my real scenario is more complicated. I'm trying to restrict the size of a popup screen to its generated content. I can't set an explicit range on the popup because I have no idea what the content is going to be like before hand. The content has to be able to restrict itself.</p>
  
  <p>Unfortunately MaxWidth and MinWidth on children are pretty much ignored. MinWidth results in cropping when the parent is set smaller. MaxWidth results in lots of empty space. It looks like I will have to set MaxWidth and MinWidth in the same place that I am dynamically updating the Width value.</p>