Button command binding not calling the binded command in Xamarin.Forms
<p>I'm currently creating a page using a ListView that is populated by data I recover from a Web API.<br>
I added 2 buttons : one to refresh the data and one to store the data locally on the device. The problem is : none of them work, the binding doesn't produce errors in the log so I'm guessing it does bind the command to the button, but when I click on it, the command is not called.</p>

<p><strong>XAML</strong>
</p>

<pre><code>&lt;ListView ItemsSource="{Binding Items}"&gt;
    &lt;ListView.ItemTemplate&gt;
        &lt;DataTemplate&gt;
            &lt;ViewCell&gt;
                &lt;StackLayout Orientation="Horizontal"&gt;
                    &lt;StackLayout.GestureRecognizers&gt;
                        &lt;TapGestureRecognizer CommandParameter="{Binding ItemId}"&gt;
                            &lt;TapGestureRecognizer.Command&gt;
                                &lt;Binding Source="{x:Reference Page}"&gt;
                                    &lt;Binding.Path&gt;BindingContext.ShowItemDataCommand&lt;/Binding.Path&gt;
                                &lt;/Binding&gt;
                            &lt;/TapGestureRecognizer.Command&gt;
                        &lt;/TapGestureRecognizer&gt;
                    &lt;/StackLayout.GestureRecognizers&gt;
                    &lt;Switch IsToggled="{Binding IsOffline}"/&gt;
                    &lt;StackLayout Orientation="Vertical"&gt;
                        &lt;Label Text="{Binding ItemTitle}"/&gt;
                        &lt;Label Text="{Binding ItemDescription}" FontSize="Micro"/&gt;
                    &lt;/StackLayout&gt;
                &lt;/StackLayout&gt;
            &lt;/ViewCell&gt;
        &lt;/DataTemplate&gt;
    &lt;/ListView.ItemTemplate&gt;
&lt;ListView.Footer&gt;
    &lt;StackLayout&gt;
        &lt;Button Text="Refresh items" HorizontalOptions="CenterAndExpand" Command="{Binding RefreshItemsCommand}"/&gt;
        &lt;Button Text="Save item data" HorizontalOptions="CenterAndExpand" Command="{Binding SaveItemData}"/&gt;
    &lt;/StackLayout&gt;
&lt;/ListView.Footer&gt;
&lt;/ListView&gt;
</code></pre>

<p><strong>Commands in the ViewModel</strong>
</p>

<pre><code>public class ItemsViewModel : INotifyPropertyChanged
{
    (...)
    public ItemsViewModel() {
        (...)
        RefreshItemsCommand = new Command(GetItemsObservableCollection);
        TogglePacksAvailabilityCommand = new Command(async () =&gt;
        {
            foreach (var i in Items.Where(i =&gt; i.IsOffline)) {
                await SaveItem(i.ItemId);
            }
        });
        (...)
    }
    (...)
    public ICommand RefreshItemsCommand { protected set; get; }
    public ICommand TogglePacksAvailabilityCommand { protected set; get; }
    (...)
}
</code></pre>

<p>The command I use for the GestureRecognizer works fine, only the buttons seem to not work, I tried to put Debug.WriteLine() in the called methods to see if they were executing, but they never write in the output log, so I assume they are not called at all.<br>
So, what could be the reason for the buttons to not call their commands ?</p>