title: Adding to ObservableCollection
body: <p>If I have a observablecollection in a page that inserts items on a listview. How can I add to that same observablecollection(listview) from a different window(class)? I do not want to use INotifyPropertyChanged and all that. All I'm trying to do is add a item to the existing listview. I have tried literally everything and I can't figure it out. Please any help is appreciated. </p>
  
  <p>CampersPage...(BindingCamper is just my way of basically saying new ObservableCollection()</p>
  
  <pre><code>  public partial class CampersPage : Page
  {
      MainWindow _parentForm;
      public GridViewColumnHeader currentColumnSorted = null;
      private SortAdorner currentAdorner = null;
      String request1;
      String request2;
      String request3;
      String request4;
     // public ObservableCollection&lt;Camper&gt; Campers { get; private set; }
  
  
      public CampersPage(MainWindow parent)
      {
          _parentForm = parent;
          InitializeComponent();
          _parentForm.bindings = new BindingCamper();
  
          for (int i = 0; i &lt; _parentForm.allCampers.Count; i++)
          {
  
  
              if (_parentForm.allCampers[i].getRequest(1) != null &amp;&amp; _parentForm.allCampers[i].getRequest(2) != null &amp;&amp; _parentForm.allCampers[i].getRequest(3) != null &amp;&amp; _parentForm.allCampers[i].getRequest(4) != null)
              {
                  request1 = _parentForm.allCampers[i].getRequest(1).getName();
                  request2 = _parentForm.allCampers[i].getRequest(2).getName();
                  request3 = _parentForm.allCampers[i].getRequest(3).getName();
                  request4 = _parentForm.allCampers[i].getRequest(4).getName();
  
              }
  
              _parentForm.bindings.Campers.Add(new Camper { FirstName = "" + _parentForm.allCampers[i].getFirstName(), LastName = "" + _parentForm.allCampers[i].getLastName(), Ages = _parentForm.allCampers[i].getAge(), SchoolGrade = _parentForm.allCampers[i].getGrade(), Gender = "" + _parentForm.allCampers[i].getGender(), bindingRequest1 = request1, bindingRequest2 = request2, bindingRequest3 = request3, bindingRequest4 = request4 });
              //DataContext = _parentForm.bindings;
          }
  
          DataContext = _parentForm.bindings;
  
  
  
      }
  </code></pre>
  
  <p>---Now I click on a button and a new window comes up where I would like to add a new camper to the listview in CampersPage.</p>
  
  <pre><code>      public partial class AddNewCamper : Window
  {
      MainWindow _parentForm;
  
  
      public AddNewCamper(MainWindow parentForm)
      {
          InitializeComponent();
          _parentForm = parentForm;
         // _parentForm.bindings = new BindingCamper();
  
      }private void btnSubmitNewCamper_Click(object sender, RoutedEventArgs e)
      {
          String firstName = txtNewFirstName.Text;
          String lastName = txtLastName.Text;
  
          int age;
          int grade;
          String newage = comboNewAge.Text;
          if (firstName != "" &amp;&amp; lastName != "" &amp;&amp; IsNumber(txtNewGrade.Text) &amp;&amp; newage != "")
          {
              age = Convert.ToInt16(newage);
              grade = Convert.ToInt16(txtNewGrade.Text);
  
              // Create New Camper
              Camper person = new Camper(age, grade, boxNewGender.Text, firstName, lastName);
  
              _parentForm.allCampers.Add(person);
              //This is just adding the camper to the listview. Not sure if it is actually adding it to the database.
              _parentForm.bindings.Campers.Add(new Camper { FirstName = person.getFirstName(), LastName = person.getLastName(), Ages = person.getAge(), SchoolGrade = person.getGrade() });
              //CampersPage p = new CampersPage(_parentForm);
              DataContext = _parentForm.bindings;
  </code></pre>
  
  <p>Do I have to somehow add AddNewCamper's namespace to CampersPage's namespace in xaml?</p>
  
  <pre><code>   &lt;ListView  HorizontalAlignment="Stretch" Margin="0,12" x:Name ="listViewCampers" ItemsSource="{Binding Campers}" DisplayMemberPath="bindMe" IsSynchronizedWithCurrentItem="True" Grid.Column="1"&gt;
  </code></pre>
  
  <p>ObservableCollection class:</p>
  
  <pre><code>      public partial class BindingCamper  
  {  // This class assist in binding campers from listview to the textboxes on the camperspage
      public ObservableCollection&lt;Camper&gt; Campers { get; set; }
      public ObservableCollection&lt;Staff&gt; StaffMembers { get; set; }
      public ObservableCollection&lt;Schedule&gt; schedule { get; set; }
      public ObservableCollection&lt;Group&gt; Groups { get; set; }
  
  
  
     public BindingCamper()
      {
        Campers = new ObservableCollection&lt;Camper&gt;();
        StaffMembers = new ObservableCollection&lt;Staff&gt;();
        schedule = new ObservableCollection&lt;Schedule&gt;();
        Groups = new ObservableCollection&lt;Group&gt;();
  
     }
  </code></pre>