title: How do I display picker control items within a custom control?
body: <p>How do I display picker control items within a custom control?</p>
  
  <p>I'm able to bind to the picker's title property with no issues.
  However, I'm unable to get ItemsSource binding to work so that I can observe picker choices.</p>
  
  <p><strong>LabelPickerPair.xaml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;ContentView
      x:Class="NewAssessment.UI.LabelPickerPair"
      xmlns="http://xamarin.com/schemas/2014/forms"
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:d="http://xamarin.com/schemas/2014/forms/design"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      x:Name="ParentControl"
      mc:Ignorable="d"&gt;
      &lt;ContentView.Content&gt;
          &lt;StackLayout&gt;
              &lt;Label FontSize="Medium" Text="{Binding Source={x:Reference ParentControl}, Path=LabelText}" /&gt;
              &lt;Picker
                  Title="{Binding Source={x:Reference ParentControl}, Path=Title}"
                  FontSize="Large"
                  ItemsSource="{Binding Source={x:Reference ParentControl}, Path=ItemsSource}"
          &lt;/StackLayout&gt;
      &lt;/ContentView.Content&gt;
  &lt;/ContentView&gt;
  </code></pre>
  
  <p><strong>LabelPickerPair.xaml.cs:</strong></p>
  
  <pre><code>namespace NewAssessment.UI
  {
      [XamlCompilation(XamlCompilationOptions.Compile)]
      public partial class LabelPickerPair : ContentView
      {
          public LabelPickerPair() =&gt; InitializeComponent();
  
          public static BindableProperty TitleProperty = BindableProperty.Create(
                  propertyName: nameof(Title),
                  returnType: typeof(string),
                  declaringType: typeof(LabelPickerPair),
                  defaultValue: "",
                  defaultBindingMode: BindingMode.TwoWay);
  
          public string Title
          {
              get { return (string)GetValue(TitleProperty); }
              set
              {
                  SetValue(TitleProperty, value);
              }
          }
  
          public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(
              nameof(ItemsSource), 
              typeof(IList ), 
              typeof(LabelPickerPair),
              defaultBindingMode: BindingMode.TwoWay,
              propertyChanged: OnItemsSourceChanged);
  
          static void OnItemsSourceChanged(BindableObject bindable, object oldValue, object newValue)
          {
              var thisControl = bindable as LabelPickerPair;
  
              if (oldValue != null)
                  thisControl.ItemsSource = oldValue as IList ;
  
              if (newValue != null)
                  thisControl.ItemsSource = newValue as IList ;
          }
  
          public IList  ItemsSource
          {
              get { 
                      var items = (IList)GetValue(ItemsSourceProperty);
                      return items; 
                  }
  
              set { SetValue(ItemsSourceProperty, value); }
          }
      }
  }
  </code></pre>