title: How do I make a WPF button look like a link?
body: <p>I want to use buttons in <strong>WPF</strong> that are styled like links. Microsoft does this (seemingly inconsistently) in its Windows dialog boxes.</p>
  
  <p>They look like blue text. And change color and underline when the mouse cursor hovers over.</p>
  
  <h2><strong>Example:</strong></h2>
  
  <p><img src="https://i.stack.imgur.com/xvZ8j.jpg" alt="LinkButton in Windows 7"></p>
  
  <p>I got it working. (thanks to <a href="https://stackoverflow.com/questions/780426/link-button-in-wpf/3564706#3564706">Christian</a>, <a href="https://stackoverflow.com/questions/780426/link-button-in-wpf/2918332#2918332">Anderson Imes</a>, and <a href="https://stackoverflow.com/questions/780426/link-button-in-wpf/780763#780763">MichaC</a>) But, I had to put a <code>TextBlock</code> inside my button. </p>
  
  <p>How can I improve my style&mdash;to make it work without requiring the TextBlock inside my Button?</p>
  
  <h2>Usage XAML</h2>
  
  <pre><code>&lt;Button Style="{StaticResource HyperlinkLikeButton}"&gt;
      &lt;TextBlock&gt;Edit&lt;/TextBlock&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <h2>Style XAML</h2>
  
  <pre><code>&lt;Style x:Key="HyperlinkLikeButton" TargetType="Button"&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="Button"&gt;
                  &lt;ContentPresenter /&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
      &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HotTrackBrushKey}}" /&gt;
      &lt;Setter Property="Cursor" Value="Hand" /&gt;
      &lt;Style.Triggers&gt;
          &lt;Trigger Property="IsMouseOver" Value="true"&gt;
              &lt;Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" /&gt;
              &lt;Setter Property="Template"&gt;
                  &lt;Setter.Value&gt;
                      &lt;ControlTemplate TargetType="Button"&gt;
                          &lt;ControlTemplate.Resources&gt;
                              &lt;Style TargetType="{x:Type TextBlock}"&gt;
                                  &lt;Setter Property="TextDecorations" Value="Underline" /&gt;
                              &lt;/Style&gt;
                          &lt;/ControlTemplate.Resources&gt;
                          &lt;ContentPresenter /&gt;
                      &lt;/ControlTemplate&gt;
                  &lt;/Setter.Value&gt;
              &lt;/Setter&gt;
          &lt;/Trigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>