title: How to do the equivalent of {Binding Source} in code?
body: <p>I'm extending a control to be able to reuse it across my current Xamarin project. As part of this control, I need to create a DataTemplate programmatically. I have this part figured out and it works ok.</p>
  
  <p>The DataTemplate has a Label in it. I need to bind the Label's BindingContext property to <code>{Binding Source}</code>. I need to bind the Label's Text property to <code>{Binding Path=Name}</code>.</p>
  
  <p>This works in XAML, but I don't want to have to copy it to a million different places in the code base.</p>
  
  <pre><code>&lt;dxGrid:TemplateColumn FieldName="MyPropertyName"
                      Caption="MyColumn"&gt;
  &lt;dxGrid:TemplateColumn.DisplayTemplate&gt;
      &lt;DataTemplate&gt;
          &lt;Label BindingContext="{Binding Source}"
                  Text="{Binding Source, Path=MyPropertyName}" /&gt;
      &lt;/DataTemplate&gt;
  &lt;/dxGrid:TemplateColumn.DisplayTemplate&gt;
  </code></pre>
  
  <p></p>
  
  <p>My extended control looks like this right now:</p>
  
  <pre><code>public class MyColumn : TemplateColumn
  {
      public MyColumn()
      {
          DataTemplate displayTemplate = new DataTemplate(() =&gt;
          {
              BindingBase textBinding = new Binding(FieldName);
  
              Label label = new Label();
  
              // TODO: Bind BindingContextProperty to {Binding Source}
              //label.SetBinding(BindingContextProperty, binding);
  
              label.SetBinding(Label.TextProperty, textBinding);
              return new ViewCell
              {
                  View = label
              };
          });
  
          DisplayTemplate = displayTemplate;
      }
  }
  </code></pre>
  
  <p>I'm getting hung up in the binding because I'm not sure how to do the equivalent of <code>{Binding Source}</code> in code. Any help would be appreciated.</p>