title: Xamarin.Forms: Add items to ListView from codebehind without binding?
body: <p>So far I've added a map and a <code>listview</code> with static items to my Form. This is what the <code>xaml</code> looks like:</p>
  
  <p>
  </p>
  
  <pre><code>&lt;StackLayout&gt;
      &lt;StackLayout VerticalOptions="FillAndExpand"&gt;
          &lt;maps:Map WidthRequest="960" HeightRequest="200"
          x:Name="MyMap"
          IsShowingUser="true"/&gt;
          &lt;ListView x:Name="ListView_Pets"&gt;
              &lt;ListView.ItemsSource&gt;
                  &lt;x:Array Type="{x:Type x:String}"&gt;
                      &lt;x:String&gt;dog&lt;/x:String&gt;
                      &lt;x:String&gt;cat&lt;/x:String&gt;
                      &lt;x:String&gt;bird&lt;/x:String&gt;
                  &lt;/x:Array&gt;
              &lt;/ListView.ItemsSource&gt;
          &lt;/ListView&gt;
      &lt;/StackLayout&gt;
  &lt;/StackLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>Instead of being static items, I would like to add them using a simple <code>foreach</code> loop. This is what the loops looks like:</p>
  
  <pre><code>    public MainPage()
      {
          InitializeComponent();
  
          string[] pets = { "dog", "cat", "bird" };
          foreach (string pet in pets)
          {
              /* Add each pet to ListView */
              //ListView_Pets.ItemsSource.Add(pet); This doesn't build
          }
      }
  </code></pre>
  
  <p>I was looking at <a href="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/listview/data-and-databinding" rel="nofollow noreferrer">ListView Data Sources</a>, but they declare a collection  <code>ObservableCollection</code> that I then bind to the <code>ListView</code>. I don't want to bind my ListView to a collection; I'm looking for the equivalent of this <code>asp.net</code> snippet (if it's possible):</p>
  
  <pre><code>foreach (string name in nameList)
  {
      DropDownList_Pets.Items.Add(new ListItem(name));
  }
  </code></pre>