title: Set Button Size to Content Size in WPF Application
body: <p>I have the following code in WPF XAML: </p>
  
  <pre><code>&lt;Window x:Class="WPFDemo.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"&gt;
  
      &lt;StackPanel&gt;
          &lt;Button Content="Hello World" Width="Auto" Height="Auto"&gt;&lt;/Button&gt;
      &lt;/StackPanel&gt;
  
  
  &lt;/Window&gt;
  </code></pre>
  
  <p>I have set the width and height of the Button to "Auto" but still it stretches the complete horizontal width. What am I doing wrong? I do not want to provide a hardcoded values for the width and height!</p>