title: Set focus of an entry from ViewModel
body: <p>I've read about messaging, triggers, behaviors, etc. ... all seems a bit overkill for what I am trying to accomplish.</p>
  
  <p>I have a repeating data entry screen in xaml that has 1 picker, 2 entries, and 1 button.  The picker, once a value is selected, keeps that selection.  The 1st entry does the same as the picker.  The 2nd entry is the one that is always getting new values.</p>
  
  <p>I want to collect the filled in values on click of the button and then clear the last entry field of its data and put focus back on that entry so the user can enter a new value and hit save.  repeat repeat repeat etc.</p>
  
  <p>I understand the MVVM model and theory - but I just want to put the focus on an entry field in the xaml view and am completely stumped.  </p>
  
  <p>EDIT to add code samples</p>
  
  <p>view.xaml:</p>
  
  <pre><code>&lt;StackLayout Spacing="5" 
               Padding="10,10,10,0"&gt;
      &lt;Picker x:Name="Direction" 
               Title="Select Direction" 
               ItemsSource="{Binding Directions}"
               ItemDisplayBinding="{Binding Name}"
               SelectedItem="{Binding SelectedDirection}"/&gt;
      &lt;Label Text="Order"/&gt;
      &lt;Entry Text="{Binding Order}" 
             x:Name="Order" /&gt;
      &lt;Label Text="Rack"/&gt;
      &lt;Entry Text="{Binding Rack}" 
             x:Name="Rack" /&gt;
      &lt;Button Text="Save" 
              Style="{StaticResource Button_Primary}" 
              Command="{Binding SaveCommand}"
              CommandParameter="x:Reference Rack" /&gt;
      &lt;Label Text="{Binding Summary}"/&gt;
  &lt;/StackLayout&gt;
  </code></pre>
  
  <p>viewmodel.cs</p>
  
  <pre><code>    public ICommand SaveCommand =&gt; new DelegateCommand&lt;View&gt;(PerformSave);
  
      private async void PerformSave(View view)
      {
          var scan = new Scan()
          {
              ScanType = "Rack",
              Direction = SelectedDirection.Name,
              AreaId = 0,
              InsertDateTime = DateTime.Now,
              ReasonId = 0,
              ScanItem = Rack,
              OrderNumber = Order,
              ScanQty = SelectedDirection.Value,
              IsUploaded = false
          };
  
          var retVal = _scanService.Insert(scan);
  
          if (!retVal)
          {
              await _pageDialogService.DisplayAlertAsync("Error", "Something went wrong.", "OK");
          }
          else
          {
              view?.Focus();
              Rack = string.Empty;
              Summary = "last scan was great";
          }
      }
  </code></pre>
  
  <p>Error shows up in this section:</p>
  
  <pre><code>private void InitializeComponent() {
          global::Xamarin.Forms.Xaml.Extensions.LoadFromXaml(this, typeof(RackPage));
          Direction = global::Xamarin.Forms.NameScopeExtensions.FindByName&lt;global::Xamarin.Forms.Picker&gt;(this, "Direction");
          Order = global::Xamarin.Forms.NameScopeExtensions.FindByName&lt;global::Xamarin.Forms.Entry&gt;(this, "Order");
          Rack = global::Xamarin.Forms.NameScopeExtensions.FindByName&lt;global::Xamarin.Forms.Entry&gt;(this, "Rack");
      }
  </code></pre>