title: How do I set focus on a Picker after selecting an item from another Picker using Prism and the MVVM way?
body: <p><strong>Scenario</strong>
  Two invisible but enabled pickers. One is for org.units, the other is for the users in the selected org.unit. The first picker is focused when the user taps on an Add (plus sign) in the ToolBar.
  When the user chooses an org.unit I need to set focus on the other picker.</p>
  
  <p><strong>Problem</strong> After selecting an orgunit it will not set the focus on the user picker.</p>
  
  <p><strong>XAML</strong></p>
  
  <pre><code>&lt;Picker
      x:Name="PickerOrgUnit"
      Title="Select an organization unit"
      IsEnabled="True"
      IsVisible="False"
      ItemDisplayBinding="{Binding OrgUnitName}"
      ItemsSource="{Binding OrgUnits, Mode=TwoWay}"
      SelectedIndexChanged="PickerOrgUnit_SelectedIndexChanged"
      SelectedItem="{Binding SelectedOrgUnit}"
      Style="{StaticResource PagePicker}"&gt;
      &lt;Picker.Behaviors&gt;
          &lt;b:EventToCommandBehavior
              Command="{Binding PickerOrgUnitItemChangedCommand}"
              CommandParameter="{x:Reference PickerOrgUnit}"
              EventName="SelectedIndexChanged" /&gt;
      &lt;/Picker.Behaviors&gt;
  &lt;/Picker&gt;
  &lt;Picker
      x:Name="PickerUser"
      Title="Select a user"
      IsEnabled="True"
      IsVisible="False"
      ItemsSource="{Binding Users, Mode=TwoWay}"
      SelectedIndexChanged="PickerUser_SelectedIndexChanged"
      SelectedItem="{Binding SelectedUser}"
      Style="{StaticResource PagePicker}"&gt;
      &lt;Picker.Behaviors&gt;
          &lt;b:EventToCommandBehavior
              Command="{Binding PickerUserItemChangedCommand}"
              CommandParameter="{x:Reference PickerUser}"
              EventName="SelectedIndexChanged" /&gt;
      &lt;/Picker.Behaviors&gt;
  &lt;/Picker&gt;
  </code></pre>
  
  <p><strong>Datamodels</strong> (simplified for easier readibility)</p>
  
  <pre><code>public class OrgUnitModel
  {
      public int OrgUnitID { get; set; }
      public string OrgUnitName { get; set; }
  }
  
  // Users here are handled in a multi-used code, named ListModel
  public class ListModel
  {
      public int ListID { get; set; }
      public string ListName { get; set; }
  }
  </code></pre>
  
  <p><strong>Code behind XAML</strong></p>
  
  <pre><code>private void PickerOrgUnit_SelectedIndexChanged(object sender, System.EventArgs e)
  {
      var vm = BindingContext as FYIUsersPageViewModel;  // this is a viemodel which handles a list of users, see below
      if (vm == null) return;
      var vmCommand = vm.PickerOrgUnitChangedCommand;
      if (vmCommand.CanExecute(sender))
          vmCommand.Execute(sender);
  }
  
  private void PickerUser_SelectedIndexChanged(object sender, System.EventArgs e)
  {
  ...
  }
  </code></pre>
  
  <p><strong>ViewModel</strong> (simplified)</p>
  
  <pre><code>public class FYIUsersPageViewModel : BindableBase, INavigationAware
  {
      public DelegateCommand&lt;object&gt; PickerOrgUnitChangedCommand =&gt; new DelegateCommand&lt;object&gt;(PickerOrgUnitChangedMethod);
      public DelegateCommand&lt;object&gt; PickerUserChangedCommand =&gt; new DelegateCommand&lt;object&gt;(PickerUserChangedMethod);
  
      private UserModel selectedOrgUnit;
      public UserModel SelectedOrgUnit { get =&gt; selectedOrgUnit; set { selectedOrgUnit = value; RaisePropertyChanged("SelectedOrgUnit"); } }
  
      private UserModel selectedUser;
      public UserModel SelectedUser { get =&gt; selectedUser; set { selectedUser = value; RaisePropertyChanged("SelectedUser"); } }
  
      public ObservableCollection&lt;OrgUnitModel&gt; OrgUnits { get; set; }  // orgunits
      public ObservableCollection&lt;ListModel&gt; Users { get; set; }  // users in an orgunit
  
      // constructor
      public FYIUsersPageViewModel(INavigationService navigationService)
      {
          NavigationService = navigationService;
  
          LoadOrgUnits();  // loads all orgunits into OrgUnits from DB
      }
  
      // code for calling OrgUnit picker, not relevant
      ...
      //
  
      public void PickerOrgUnitChangedMethod(object obj)
      {
          OrgUnitModel selItem = (OrgUnitModel)((Picker)obj).SelectedItem;
          if (selItem == null)
              return;
          LoadUsers(selItem.OrgUnitID);  // load orgunit users from DB
          Picker picker = (Picker)obj;
  
          // THIS IS WHAT DOES NOT WORK! Because I call the orgunit picker here, not the user picker... HELP NEEDED HERE!
          Device.BeginInvokeOnMainThread(() =&gt;
          {
              if (picker.IsFocused)
                  picker.Unfocus();
              picker.Focus();
          });
          picker.Focus();
      }
  
      public void PickerUserChangedMethod(object obj)
      {
          // Goal reached, do something with the selected user.
          // BUT I NEVER GET HERE!
      }
  }
  </code></pre>