title: Xamarin MvvM contentview binding
body: <p>I've developing an App with Xaramin.</p>
  
  <p>In my solution I've created a ContentView.xaml, as a custom GUI control.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ContentView xmlns="http://xamarin.com/schemas/2014/forms"
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:local="clr-namespace:test2;assembly=test2"
      x:Class="test2.MyView"&gt;
  
      &lt;ContentView.BindingContext&gt;
          &lt;local:MyViewModel MyValue="1"/&gt;
      &lt;/ContentView.BindingContext&gt;
  
      &lt;StackLayout&gt;
          &lt;Label HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Text="{Binding MyValue}"/&gt;
      &lt;/StackLayout&gt;
  
  &lt;/ContentView&gt;
  </code></pre>
  
  <p>I've created a ViewModel Class for this ContentView:</p>
  
  <pre><code>using System;
  using System.ComponentModel;
  using Xamarin.Forms;
  
  namespace test2
  {
      public class MyViewModel : INotifyPropertyChanged
      {
          int myValue;
  
          public MyViewModel()
          {
              Device.StartTimer (TimeSpan.FromSeconds (1), () =&gt; {
  
                  this.MyValue++;
                  return true;
              });
          }
  
          public int MyValue
          {
              set
              {
                  if (! myValue.Equals(value)) {
  
                      myValue = value;
                      OnPropertyChanged ("myValue");
                  }
              }
              get
              { 
                  return myValue;
              }
          }
  
          public event PropertyChangedEventHandler PropertyChanged;
  
          protected void OnPropertyChanged(string propertyName)
          {
              if (PropertyChanged != null) {
  
                  PropertyChanged (this, new PropertyChangedEventArgs (propertyName));
              }
          }
      }
  }
  </code></pre>
  
  <p>I've also created a ContentPage.xaml, and added my custom control in it.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:local="clr-namespace:test2;assembly=test2"
      x:Class="test2.MyPage"&gt;
  
      &lt;local:MyView /&gt;
  
  &lt;/ContentPage&gt;
  </code></pre>
  
  <p>I found the Label never update, why?</p>