title: Embedded hyperlinks in WPF and localization
body: <p>I have a TextBlock in a WPF application where I'd like to show the user a message similar to:</p>
  
  <p><a href="http://stackoverflow.com">Retry</a> or <a href="http://stackoverflow.com">go back.</a></p>
  
  <p>I can accomplish this by doing:</p>
  
  <pre><code>&lt;TextBlock&gt;
      &lt;Hyperlink Command="{Binding RetryCommand}"&gt;
          &lt;Run Text="Retry" /&gt;
      &lt;/Hyperlink&gt;
      &lt;Run Text=" or " /&gt;
      &lt;Hyperlink Command="{Binding GoBackCommand}"&gt;
          &lt;Run Text="go back." /&gt;
      &lt;/Hyperlink&gt;
  &lt;/TextBlock&gt;
  </code></pre>
  
  <p>However, this solution is not very friendly to localization; it is particularly problematic in the case where sentences require rearranging in the process of localization. I would much prefer to be able to specify something like <code>"[Retry]({0}) or [go back.]({1})."</code> in a resx file and dynamically insert the hyperlinks into the localized string. Is there a clean and simple way to go about doing this?</p>
  
  <p>In another application, we used a surprisingly complex solution involving extending the TextBlock class and dynamically constructing the Inlines property, but it seemed like a lot of code for what should be a common problem.</p>
  
  <p>Related questions: <a href="https://stackoverflow.com/questions/6122490/is-adding-strings-with-placeholders-0-into-resources-a-good-idea">Is adding strings with placeholders (`{0}`) into resources a good idea?</a>, <a href="https://stackoverflow.com/questions/1746693/how-to-embed-links-in-localized-text">How to embed links in localized text</a></p>