title: Dynamically formatted TextBlock
body: <p>I would like to format specific words in TextBlock dynamically, because it is binded to my object. I was thinking about using Converter but using following solution add only tags directly to the text (instead of showing it formatted).</p>
  
  
  
  <pre class="lang-cc prettyprint-override"><code>public class TextBlockFormatter : IValueConverter {
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
          string regexp = @"\p{L}+#\d{4}";
  
          if (value != null) {
              return Regex.Replace(value as string, regexp, m =&gt; string.Format("&lt;Bold&gt;{0}&lt;/Bold&gt;", m.Value));
          } 
  
          return null;
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
          return null;
      }
  }
  </code></pre>