title: Non breaking space in XAML vs. code
body: <p>This works fine, and correctly inserts non-breaking spaces into the string:  </p>
  
  <pre><code>&lt;TextBlock Text="Non&amp;#160;Breaking&amp;#160;Text&amp;#160;Here"&gt;&lt;/TextBlock&gt;
  </code></pre>
  
  <p>But what I really need is to replace spaces with non-breaking spaces during data binding. So I wrote a simple value converter that replaces spaces with "<code>&amp;#160;</code>". It does indeed replace spaces with "<code>&amp;#160;</code>" but "<code>&amp;#160;</code>" is displayed literally instead of showing as a non-breaking space. This is my converter:  </p>
  
  <pre><code>public class SpaceToNbspConverter : IValueConverter
  {
      #region IValueConverter Members
  
      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
      {
          return value.ToString().Replace(" ", "&amp;#160;");
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  
      #endregion
  }
  </code></pre>
  
  <p>Does anybody know why it works in XAML, but not in code?  </p>