title: Mvvmlight, Xamarin.iOS nested binding in ObservableCollection item
body: <p>I'm building a cross platform solution using Xamarin.iOS and mvvmlight as mvvm framework.</p>
  
  <p>I have run into a problem with nested bindings. I'm trying to accomplish the following windows phone example in Xamarin.iOS:</p>
  
  <p>I have an observable collection of type <code>NewsItem</code> called <code>NewsList</code> that I bind to the <code>Listview</code></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;ListView ItemsSource="{Binding NewsList}" &gt;
  </code></pre>
  
  <p>This list is initially populated with news items that have empty images. As images are loading each item has its image property updated.</p>
  
  <p>The image property of the <code>NewsItem</code> model raises property changed events when set.</p>
  
  <p>And the image source binding is created in the <code>ListView.ItemTemplate</code> in xaml:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;ListView.ItemTemplate&gt;
      &lt;DataTemplate&gt;
  ...
  &lt;Image Source="{Binding Image}" /&gt;
  </code></pre>
  
  <p>This binding works on Windows Phone. Images are updated initially when collection is populated and images are updated when loaded.</p>
  
  <p>However when trying to set this binding in Xamarin.iOS, I experience problems. 
  Following the example given of iOS bindings I use the <code>GetController</code> function on the <code>ObservableCollection</code>:</p>
  
  <pre class="lang-cs prettyprint-override"><code>newsTableViewController = NewsListHolder.GetController(CreateNewsCell, BindNewsCell);
  </code></pre>
  
  <p>In <code>BindNewsCell</code> I try to set the image binding, much like in the windows phone example above. This is however proving difficult:</p>
  
  <pre class="lang-cs prettyprint-override"><code>private void BindNewsCell(UITableViewCell cell, NewsItem news, NSIndexPath path)
  {
      // Reference for UI elements in cell
      var titleLabel = cell.ViewWithTag (100) as UILabel;
      var dateLabel = cell.ViewWithTag (101) as UILabel;
      var imageView = cell.ViewWithTag (102) as UIImageView;
  
      // Set values in cell
      titleLabel.Text = news.Title;
      dateLabel.Text = news.Date;
  
      // The line commented out below works in setting the image, but does not update
      // when the image property changes, only when the cells are redrawn. 
      //imageView.Image = ValueConverter.IBitmapToUIImage(news.Image);
  
      this.SetBinding (
              () =&gt; news.Image,
              () =&gt; imageView.Image)
              .ConvertSourceToTarget(ValueConverter.IBitmapToUIImage);
  }
  </code></pre>
  
  <p>This binding does not work. I also tried using:</p>
  
  <pre class="lang-cs prettyprint-override"><code>this.SetBinding(
      () =&gt; news.Image)
      .WhenSourceChanges(
          () =&gt;
          {
              imageView.Image = ValueConverter.IBitmapToUIImage(news.Image);            
          });
  </code></pre>
  
  <p>without success. </p>
  
  <p>I can do regular binding:</p>
  
  <pre class="lang-cs prettyprint-override"><code>private Binding&lt;bool, bool&gt; testBinding;
  
  // Set test binding
  testBinding = this.SetBinding (
      () =&gt; Vm.Test,
      () =&gt; TestIndicator.Hidden));
  </code></pre>
  
  <p>works fine.</p>
  
  <p>How do you bind to properties in dynamically created items in a observable collection?</p>
  
  <p><strong>Edit: I have revised the over-simplified above code samples to include a little more detail on the image conversion.</strong></p>
  
  <p><strong>To boil down the question: Using mvvmlight in xamarin.ios, how do i implement data binding on a specific property of an item in an observable list of said items?</strong></p>