title: Bind Drawable Background Color with MVVM light in Xamarin.Android
body: <p>I am using MVVM light within my Xamarin.Android project and would like to bind my <code>MainViewModel</code>'s <code>StatusColor</code> property to the background of a <code>GradientDrawable</code> which acts as background of an <code>ImageView</code> control.</p>
  
  <p>Unfortunately, a <code>GradientDrawable</code> does not have any <code>Color</code> property that I could bind my color to, just a <code>SetColor(int)</code> method. Is there a way to tell MVVM light to always call this <code>SetColor(int)</code> method whenever the <code>StatusColor</code> property of my <code>MainViewModel</code> changes?</p>
  
  <p>The ugly(!) alternative would be to fire an event when the ViewModel changes the color property, but I really want to avoid that...</p>
  
  <p>My code currently looks like this:</p>
  
  <pre><code>// This does not work!
  this.SetBinding(
      () =&gt; MainViewModel.StatusColor,
      () =&gt; ((GradientDrawable)IvStatus.Background).Color); // There is no GradientDrawable.Color property...
  </code></pre>
  
  <p>If it helps, here is my <code>IvStatus</code> control and the <code>Drawable</code> its background is set to:</p>
  
  <p><strong><code>IvStatus</code>:</strong></p>
  
  <pre><code>&lt;ImageView
      android:id="@+id/ivStatus"
      android:background="@drawable/Circle"                                    
      android:layout_width="10dip"
      android:layout_height="10dip"
      android:layout_gravity="center_vertical" /&gt;
  </code></pre>
  
  <p><strong><code>Circle.xml</code>:</strong></p>
  
  <pre><code>&lt;shape
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:shape="oval"&gt;
      &lt;solid android:color="#cccccc"/&gt;
      &lt;stroke
          android:width="1dip"
          android:color="#333333"/&gt;
  &lt;/shape&gt;
  </code></pre>