title: Setting a default page in the Xamarin.Forms shell menu
body: <p>Using the Xaminals example, I'm trying to set the default startup page. Here's the relevant code from the xaml:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;FlyoutItem Route=&quot;animals&quot; x:Name=&quot;shellAnimals&quot;
              Title=&quot;Animals&quot;
              FlyoutDisplayOptions=&quot;AsMultipleItems&quot;&gt;
      &lt;Tab Title=&quot;Domestic&quot; x:Name=&quot;shellDomestic&quot;
           Route=&quot;domestic&quot;
           Icon=&quot;paw.png&quot;&gt;
          &lt;ShellContent Route=&quot;cats&quot; x:Name=&quot;shellCats&quot;
                        Style=&quot;{StaticResource DomesticShell}&quot;
                        Title=&quot;Cats&quot;
                        Icon=&quot;cat.png&quot;
                        ContentTemplate=&quot;{DataTemplate views:CatsPage}&quot; /&gt;
          &lt;ShellContent Route=&quot;dogs&quot; x:Name=&quot;shellDogs&quot;
                        Style=&quot;{StaticResource DomesticShell}&quot;
                        Title=&quot;Dogs&quot;
                        Icon=&quot;dog.png&quot;
                        ContentTemplate=&quot;{DataTemplate views:DogsPage}&quot; /&gt;
      &lt;/Tab&gt;
      &lt;ShellContent Route=&quot;monkeys&quot; x:Name=&quot;shellMonkeys&quot;
                    Style=&quot;{StaticResource MonkeysShell}&quot;
                    Title=&quot;Monkeys&quot;
                    Icon=&quot;monkey.png&quot;
                    ContentTemplate=&quot;{DataTemplate views:MonkeysPage}&quot; /&gt;
      &lt;ShellContent Route=&quot;elephants&quot; x:Name=&quot;shellElephants&quot;
                    Style=&quot;{StaticResource ElephantsShell}&quot;
                    Title=&quot;Elephants&quot;
                    Icon=&quot;elephant.png&quot;
                    ContentTemplate=&quot;{DataTemplate views:ElephantsPage}&quot; /&gt;
      &lt;ShellContent Route=&quot;bears&quot; x:Name=&quot;shellBears&quot;
                    Style=&quot;{StaticResource BearsShell}&quot;
                    Title=&quot;Bears&quot;
                    Icon=&quot;bear.png&quot;
                    ContentTemplate=&quot;{DataTemplate views:BearsPage}&quot; /&gt;
  &lt;/FlyoutItem&gt;
  </code></pre>
  <p>In the code behind I can successfully set the default startup page.</p>
  <p>For example, the dogs page:</p>
  <pre class="lang-cs prettyprint-override"><code>shellAnimals.CurrentItem.CurrentItem = shellDogs;
  </code></pre>
  <p>But on the bears page:</p>
  <pre class="lang-cs prettyprint-override"><code>// This works, but I don't like the indexing. Will give trouble on dynamic menu's
  shellAnimals.CurrentItem = shellAnimals.Items[3];
  
  // This doesn't work, but I don't understand why. It gives a null reference exception in the Xamarin Shell code, on the PushAsync
  shellAnimals.CurrentItem = shellBears;
  
  // This shows the bears page at startup, but when I click on an item in the listview, I also get a null reference error
  CurrentItem = shellBears;
  </code></pre>
  <ol>
  <li>Why doesn't the second/third snippet work?</li>
  <li>How can I set the default page to the bears page without using the indexer?</li>
  </ol>
  <p>Can't find anything on this subject except <a href="https://stackoverflow.com/questions/56812252/set-default-tab-on-xamarin-forms-shell">Set default tab on Xamarin Forms Shell</a> but that doesn't answer it.</p>