title: How can I make a formatted TextBlock width data binding localizable?
body: <p>In my WPF application, I would like to display something that looks like this:</p>
  
  <blockquote>
    <p>User <strong>Bob</strong> has logged off at <strong>22:17</strong>.</p>
  </blockquote>
  
  <p>Where "Bob" and "22:17" are data-bound values.</p>
  
  <p>The obvious way to do this would be to use a <code>StackPanel</code> with multiple <code>TextBlock</code> children, some of them data bound:</p>
  
  <pre><code>&lt;StackPanel Orientation="Horizontal"&gt;
     &lt;TextBlock Text="The user"/&gt;
     &lt;TextBlock Text="{Binding Path=Username}" TextBlock.FontWeight="Bold" /&gt;
     &lt;TextBlock Text="has logged off at"/&gt;
     &lt;TextBlock Text="{Binding Path=LogoffTime}" TextBlock.FontWeight="Bold" /&gt;
  &lt;/StackPanel/&gt;
  </code></pre>
  
  <p>This works, but it's ugly. The program is supposed to be localized to different languages, and having separate strings for "The user" and "has logged off at" is a recipie for localization disaster.</p>
  
  <p>Ideally, I would like to do something like this:</p>
  
  <pre><code>&lt;TextBlock&gt;
       &lt;TextBlock.Text&gt;
           &lt;MultiBinding StringFormat="{}The user &lt;Bold&gt;{0}&lt;/Bold&gt; has logged off at &lt;Bold&gt;{1}&lt;/Bold&gt;"&gt;
               &lt;Binding Path="Username" /&gt;
               &lt;Binding Path="LogoffTime" /&gt;
           &lt;/MultiBinding&gt;
  &lt;/TextBlock&gt;
  </code></pre>
  
  <p>So the translator would see a complete sentence <code>The user &lt;Bold&gt;{0}&lt;/Bold&gt; has logged off at &lt;Bold&gt;{1}&lt;/Bold&gt;</code>. But that doesn't work, of course. </p>
  
  <p>This has to be a common problem, what's the right solution for this?</p>