title: Xamarin label binding
body: <p>So I've recently just re-worked my larger app project structure to MVVM, however, I'm trying to do simple label binding and I cannot get anything to work at all. I'm probably just being somewhat stupid and missing an obvious thing here but I cannot figure this out. I'm not currently trying to do this in an ObservableCollection because I can't even get the basics to work currently. Just a simple Label.</p>
  
  <p>My TaskModel class contains</p>
  
  <pre><code>public class TaskModel
  {
      public string Title { get; set; }
  }
  </code></pre>
  
  <p>My MainViewModel contains</p>
  
  <pre><code>public class MainViewModel
  {
      TaskModel task = new TaskModel
      {
          Title = "Hello"
      };
  }
  </code></pre>
  
  <p>My MainPage Xaml contains</p>
  
  <pre><code>&lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
           xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
           xmlns:local="clr-namespace:Testing"
           x:Class="Testing.MainPage"
           xmlns:bc="clr-namespace:Testing.ViewModels"&gt;
  
  &lt;ContentPage.Padding&gt;
      &lt;OnPlatform x:TypeArguments="Thickness" 
                  iOS="0, 20, 0, 0"
                  Android="0, 40, 0, 0"&gt;
      &lt;/OnPlatform&gt;
  &lt;/ContentPage.Padding&gt;
  
  &lt;StackLayout BindingContext="{x:Reference Slider}" HorizontalOptions="Center" VerticalOptions="Center"&gt;
      &lt;BoxView Color="Green" Opacity="{Binding Value}"&gt;&lt;/BoxView&gt;
      &lt;Label BindingContext="{x:Reference Slider}" Text="{Binding 
          Value, 
          StringFormat='Value is {0:F2}'}"
          Opacity="{Binding Value}"&gt;
      &lt;/Label&gt;
      &lt;Slider x:Name="Slider" &gt;&lt;/Slider&gt;
      &lt;Label Text="{Binding TaskModel.Hello}"&gt;&lt;/Label&gt;
  
  &lt;/StackLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>And then my MainPage.Xaml.CS contains</p>
  
  <pre><code>public partial class MainPage : ContentPage
  {
      public MainPage()
      {
          InitializeComponent();
          BindingContext = new MainViewModel();
      }
  }
  </code></pre>
  
  <p>So as you can see, nothing too special. Feeling a bit stupid that I can't work this out and any assistance on this matter would be greatly appreciated!</p>
  
  <p>EDIT:</p>
  
  <p>Ignore the extra XAML, the XAML above the label at the base is just me testing other binding within the same XAML page, which works, just trying to get it to bind outside of the page if you get what I'm saying.</p>