title: How do i add items to a observablecollection from another list view
body: <p>Hi I am a beginner with Xamarin forms and need some help. I have tried looking for this method everywhere.</p>
  <p>I have a List view with a lot of animal names. When a item is clicked it shows more info about that particular animal. I have added a button that is on each animals info page. I would like to click that &quot;add&quot; button, that would then add the name off the animal to another List view.</p>
  <p>But I am stuck on how to do this, any help would be greatly appreciated.</p>
  <p>this is the first list page in code behind</p>
  <pre><code>public partial class BirdListAZ : ContentPage
      {
          IEnumerable&lt;birdlistmodel&gt; GetBirds(string searchText = null)
          {
              var birds = new List&lt;birdlistmodel&gt;
              {
                  new birdlistmodel (){Id = 1, BirdNames = &quot;Apalis, Bar-throated&quot; }, 
                  new birdlistmodel (){Id = 2, BirdNames = &quot;Apalis, Yellow-breasted&quot;},//there are alot more birds here
          
              };
              if (String.IsNullOrWhiteSpace(searchText))
                  return birds;
              var lowerBirds = searchText.ToLower();
              return birds.Where(c =&gt; c.BirdNames.ToLower().StartsWith(lowerBirds));
          }
  
          public BirdListAZ()
          {
              InitializeComponent();
              blistview.ItemsSource = GetBirds();
          }
  
          private void SearchBar_TextChanged(object sender, TextChangedEventArgs e)
          {
              blistview.ItemsSource = GetBirds(e.NewTextValue);
          }
  
          private void blistview_ItemSelected(object sender, SelectedItemChangedEventArgs e)
          {
              var birds = e.SelectedItem as birdlistmodel;
              Navigation.PushAsync(new BirdPages(birds.BirdNames, birds.BirdSelect));
          }
      }
  }
  </code></pre>
  <p>this is the content page for that code behind</p>
  <pre><code> &lt;ScrollView HeightRequest=&quot;3000&quot;&gt;
              &lt;StackLayout&gt;
                  &lt;SearchBar 
                      TextChanged=&quot;SearchBar_TextChanged&quot;
                      Placeholder=&quot;Search Bird&quot;
                      PlaceholderColor=&quot;Gray&quot;
                      HorizontalTextAlignment=&quot;Center&quot;
                      FontSize=&quot;Small&quot;
                      FontAttributes=&quot;Italic&quot;
                      VerticalOptions=&quot;Center&quot; HorizontalOptions=&quot;Start&quot;/&gt;
                  &lt;ListView x:Name=&quot;blistview&quot; BackgroundColor =&quot;AliceBlue&quot; HasUnevenRows=&quot;True&quot; ItemSelected=&quot;blistview_ItemSelected&quot;&gt;
                      &lt;ListView.ItemTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;ViewCell&gt;
                                  &lt;StackLayout Orientation=&quot;Horizontal&quot; Padding=&quot;5&quot;&gt;
                                      &lt;Label Text=&quot;{Binding BirdNames}&quot; HorizontalOptions=&quot;StartAndExpand&quot; VerticalOptions=&quot;Center&quot;/&gt;
                                      
                                  &lt;/StackLayout&gt;
                              &lt;/ViewCell&gt;
                          &lt;/DataTemplate&gt;
  
                      &lt;/ListView.ItemTemplate&gt;
                  &lt;/ListView&gt;
              &lt;/StackLayout&gt;
          &lt;/ScrollView&gt;
  </code></pre>
  <p>when item is clicked on list it displays that info in a separate page
  the contentpage</p>
  <pre><code>   &lt;ContentPage.Content&gt;
          &lt;StackLayout&gt;
              &lt;Label x:Name=&quot;BirdNameCall&quot; FontSize=&quot;30&quot; FontAttributes=&quot;Bold&quot;
                  VerticalOptions=&quot;StartAndExpand&quot; 
                  HorizontalOptions=&quot;CenterAndExpand&quot; /&gt;
              &lt;Button Text=&quot;+&quot; x:Name=&quot;AddToList&quot; VerticalOptions=&quot;Center&quot; HorizontalOptions=&quot;Center&quot; WidthRequest=&quot;200&quot; HeightRequest=&quot;100&quot; 
                      FontSize=&quot;30&quot; BackgroundColor=&quot;Transparent&quot; Clicked=&quot;AddToList_Clicked&quot;/&gt;
          &lt;/StackLayout&gt;
      &lt;/ContentPage.Content&gt;
  &lt;/ContentPage&gt;
  </code></pre>
  <p>So this is what i have done. I know the filewritealltext makes a new file each time. how can i just add to that file so a new file is not created?</p>
  <pre><code> public BirdPages(string BirdNames, Button BirdSelect)
          {
              InitializeComponent();
  
              BirdNameCall.Text = BirdNames;
              AddToList = BirdSelect;
              localPath = Path.Combine(FileSystem.AppDataDirectory, birdfile);
          }
  
          const string birdfile = &quot;birdlist.txt&quot;;
  
          string localPath;
          private void AddToList_Clicked(object sender, EventArgs e)
          {
              string BirdNames = BirdNameCall.Text;
              File.WriteAllText(localPath, BirdNames);
              DisplayAlert(BirdNames, &quot;added to list&quot;, &quot;Ok&quot;);
          }
  </code></pre>
  <p>So it works when i populate the list view but it will be a letter per row and not the entire string in a row</p>
  <pre><code>public partial class myBirdList : ContentPage
      { 
     
          public myBirdList()
          {
              InitializeComponent();
              localPath = Path.Combine(FileSystem.AppDataDirectory, birdfile);
  
              birdlistview.ItemsSource = File.ReadAllText(localPath);
  
  
  
          }
          const string birdfile = &quot;birdlist.txt&quot;;
          string localPath;
      }
  </code></pre>