title: Xamarin Forms: Call Command of ViewModel from DataTemplate
body: <p>I am stuck on a binding problem here.</p>
  
  <p>I created a bindable layout which is inside a control template:</p>
  
  <pre><code>&lt;ContentView x:Name="SettingsMenu" ControlTemplate="{StaticResource HeaderTemplate}" AbsoluteLayout.LayoutBounds="0.5,0.5,1,1" 
  AbsoluteLayout.LayoutFlags="All"&gt;               
      &lt;ScrollView Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"&gt;                   
          &lt;StackLayout x:Name="SettingsStack" BindableLayout.ItemsSource="{Binding Settings}" BindableLayout.ItemTemplateSelector="{StaticResource SettingsSelectorTemplate}" Orientation="Vertical" Spacing="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" /&gt;           
      &lt;/ScrollView&gt;        
  &lt;/ContentView&gt;
  </code></pre>
  
  <p>What I want to do is call a command inside the view model. The call is inside a item template selector as a resource dictionary inside App.xml</p>
  
  <pre><code>&lt;ResourceDictionary&gt;
      &lt;DataTemplate x:Key="PlaceholderSettingsTemplate"&gt;
          ### SOME STUFF
       &lt;/DataTemplate&gt;
       &lt;DataTemplate x:Key="HeaderSettingsTemplate"&gt;
               ### SOME STUFF
           &lt;Grid ...&gt;
               &lt;Grid.GestureRecognizers&gt;
                   &lt;TapGestureRecognizer Tapped="ButtonClick" Command="{Binding BindingContext.SettingsTap, Source={x:Reference SettingsPage}}" CommandParameter="{Binding}" /&gt;  ########## &lt;--------- WHAT TO USE FOR SOURCE?
               &lt;/Grid.GestureRecognizers&gt;
           &lt;/Grid&gt;
       &lt;/DataTemplate&gt;
       &lt;data:SettingsSelector x:Key="SettingsSelectorTemplate" Placeholder="{StaticResource PlaceholderSettingsTemplate}" Heading="{StaticResource HeaderSettingsTemplate}" Content="{StaticResource ContentSettingsTemplate}" /&gt;
  &lt;/ResourceDictionary&gt;
  </code></pre>
  
  <p>Before I moved it inside a resource dictionary in the App.xml file, I simply used the x:Name of the Parent Contentview. But: I can't reference it by name anymore because I moved it into a resource dictionary inside App.xml.</p>
  
  <p>Now, the answer may be trivial but I just can't find a solution.</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Kind regards</p>