title: Xamarin Forms Shell ToolbarItem Not responding to Command Binding
body: <p>I am in the process of converting a Xamarin Forms non Shell app over to the Shell format. I have encountered an issue where a <code>ToolbarItem</code> defined on a <code>ContentPage</code> is not responding to the bound <code>Command</code> when it changes its executable status. I have verified this by adding standard buttons into the same page and have bound them to the same <code>Command</code> as per the below xaml.</p>
  
  <pre><code>&lt;ContentPage.ToolbarItems&gt;
      &lt;ToolbarItem Text="Edit" Priority="1" Command="{Binding ToggleEditCommand}" Order="Primary"
                   Icon="{OnPlatform Android=ic_edit_white_24dp.png, UWP=Assets/Icons/ic_edit_dark_48dp.png}"/&gt;
      &lt;ToolbarItem Text="Save" Priority="2" Command="{Binding SaveItemCommand}" Order="Primary"
                   Icon="{OnPlatform Android=ic_save_white_24dp.png, UWP=Assets/Icons/ic_save_dark_48dp.png}"/&gt;
      &lt;ToolbarItem Text="Copy" Priority="3" Command="{Binding CopyItemCommand}" Order="Secondary"
                   Icon="{OnPlatform Android=ic_content_copy_white_24dp.png, UWP=Assets/Icons/ic_content_copy_dark_48dp.png}"/&gt;
      &lt;ToolbarItem Text="Delete" Priority="4" Command="{Binding DeleteItemCommand}" Order="Secondary"
                   Icon="{OnPlatform Android=ic_delete_white_24dp.png, UWP=Assets/Icons/ic_delete_dark_48dp.png}"/&gt;
  
  &lt;/ContentPage.ToolbarItems&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="auto"/&gt;
          &lt;RowDefinition Height="*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;StackLayout&gt;
          &lt;Button Text="edit" Command="{Binding ToggleEditCommand}"/&gt;
          &lt;Button Text="Save" Command="{Binding SaveItemCommand}"/&gt;
          &lt;Button Text="Copy" Command="{Binding CopyItemCommand}"/&gt;
          &lt;Button Text="Delete" Command="{Binding DeleteItemCommand}"/&gt;
      &lt;/StackLayout&gt;
      &lt;editviews:GameActionEditView IsVisible="{Binding IsVMInEditMode}" Grid.Row="1"/&gt;
      &lt;Grid IsVisible="{Binding IsVMInViewMode}" Grid.Row="1"&gt;
          &lt;viewonly:GameActionView BindingContext="{Binding SelectedGameAction}"/&gt;
      &lt;/Grid&gt;
  </code></pre>
  
  <p>When I navigate to the page, it responds and updates the view model as expected, which in turn updates the various <code>Command</code> objects and the buttons, but not the <code>ToolbarItems</code> bound to the same <code>Command</code>. The below gif's don't display my attempts at clicking on the <code>ToolbarItem</code> to save, but I am doing so during the gap from typing 'effect' and pressing the save button.</p>
  
  <p>this is on forms version 4.3.0.991211</p>
  
  <p>Is there a known bug? Is there a workaround?</p>
  
  <p><a href="https://i.stack.imgur.com/Qblo8.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qblo8.gif" alt="ToolbarItemNotUpdating1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/Aw78S.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Aw78S.gif" alt="ToolbarItemNotUpdating2"></a></p>
  
  <p><strong>EDIT: Viewmodel Code</strong></p>
  
  <p>As requested, here is the ViewModel Code. Constructor:</p>
  
  <pre><code>public GameActionVM()//GameActionsViewModel gameActionsViewModel)
      {
          //_parentCollectionVM = ((App)Application.Current).viewModel._gamemActionsVM ?? null;
          _isVMInEditMode = false;
          _isVMInViewMode = true;
          ActionCosts = new ObservableCollection&lt;ActionCost&gt;();
          ToggleEditCommand = new Command(ToggleEditMode, CanToggleEditMode);
          CopyItemCommand = new Command(async () =&gt; await CopyItemAsync(), CanCopyItem);
          SaveItemCommand = new Command(async () =&gt; await SaveItemAsync(), CanSaveItem);
          DeleteItemCommand = new Command(async () =&gt; await DeleteItemAsync(), CanDeleteItem);
          ShowUserContentWarningCommand = new Command(async () =&gt; await ShowUserContenWarningAsync(), CanShowUserContentWarning);
          RePopulateReferenceTypesAsync();
      }
  </code></pre>
  
  <p>Propetychanged listener to call the Can Execute method</p>
  
  <pre><code>protected override void OnPropertyChanged(PropertyChangedEventArgs e)
      {
          base.OnPropertyChanged(e);
          switch (e.PropertyName)
          {
              case "Title":
              case "Effect":
              case "SelectedActionCost":
                  HasUnsavedChanges = CheckForUnsavedChanges();
                  SaveItemCommand.ChangeCanExecute();
                  break;
              case "IsVMInEditMode":
                  IsVMInViewMode = !IsVMInEditMode;
                  CopyItemCommand.ChangeCanExecute();
                  SaveItemCommand.ChangeCanExecute();
                  DeleteItemCommand.ChangeCanExecute();
                  ToggleEditCommand.ChangeCanExecute();
                  break;
          }
      }
  </code></pre>
  
  <p>And finally the Can Execute method for the save command;</p>
  
  <pre><code>protected override bool CanSaveItem()
      {
          if (!IsVMInEditMode) return false;
          if (string.IsNullOrWhiteSpace(Title)) return false;
          if (string.IsNullOrWhiteSpace(Effect)) return false;
          if (Title.Length &gt; 40) return false;
          if (Effect.Length &gt; 1000) return false;
          if (SelectedActionCost == null) return false;
          return true;
      }
  </code></pre>
  
  <p>**EDIT 2: Repo link added **
  I've managed to reproduce the issue in the Shell template straight out of Visual Studio (2019, v16.4.0). Repo can be found <a href="https://github.com/ExquisiteMonkey/ShellTest" rel="nofollow noreferrer">on GITHUB</a></p>