title: Size-to-content-layout problem in WPF
body: <p>This is supposed to be a no brainer but I still can’t figure it out.</p>
  
  <p>In my sample app there’s a <strong>button</strong> and a <strong>textbox</strong> in a <strong>dockpanel</strong>. If the content of the textbox is smaller than the content of the textbox the window is as big as it needs to be to display the content of the button. That’s what I want. But if I put more text into the textbox the window gets wider :-(</p>
  
  <p><em>The behavior I want is that the window gets the width according to the buttons content and the textbox wraps its content (or/and shows scrollbars if necessary).</em></p>
  
  <p>Thank you!</p>
  
  <p>Some sample code:</p>
  
  <pre><code>&lt;Window x:Class="SO1.Window1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      Title="Window1" SizeToContent="Width" FontSize="20"&gt;
      &lt;DockPanel&gt;
          &lt;Button DockPanel.Dock="Top"&gt;A rather long text&lt;/Button&gt;
          &lt;TextBlock TextWrapping="Wrap"&gt;Short text&lt;/TextBlock&gt;
      &lt;/DockPanel&gt;
  &lt;/Window&gt;
  </code></pre>