title: How to bind WPF element colors without the view model knowing about WPF?
body: <p>I'm wondering how to bind a color property of an element to the ViewModel without leaking the view implementation (e.g. WPF) into the ViewModel and thus creating a dependency.  For example, I have a <code>TextBlock</code> and I've bound its <code>Foreground</code> property like this:</p>
  
  <pre><code>&lt;TextBlock Name="MyTextBlock" Foreground="{Binding Path=PropName}" /&gt;
  </code></pre>
  
  <p>Many sources like <a href="https://stackoverflow.com/questions/5601489/how-can-i-bind-foreground-to-a-property-in-my-viewmodel">this</a>, <a href="https://stackoverflow.com/questions/12012167/changing-the-background-color-of-a-textblock-in-mvvm-wpf-and-retaining-it">this</a>, <a href="https://stackoverflow.com/questions/7329812/change-button-background-color-through-mvvm-pattern-in-wpf">this</a>, etc. use <code>System.Windows.Media.Brush</code> from within the ViewModel, like this:</p>
  
  <pre><code>public System.Windows.Media.Brush PropName
  {
      get
      {
          //assume presentation logic to determine correct color.
          return System.Windows.Media.Brushes.Red;
      }
  }
  </code></pre>
  
  <p>I don't want my ViewModel to be tied to WPF (i.e. via <code>System.Windows.Media.Brush</code>) or any other presentation framework.  Is there some way of doing it so that I can use a general or universal color type or even an RGB value and have it interpreted correctly in the XAML from the binding?</p>