title: creating an observable collection from XML file read
body: <p>I have an xml file like this</p>
  
  <pre><code>&lt;Root&gt;
    &lt;Day id="Monday"&gt;
      &lt;subject name="Software Testing" session="2010" group="Alpha" teacher="Tasawar Khan" classroom="Class Room 1" time="8:30"&gt;
  
      &lt;/subject&gt;
    &lt;/Day&gt;
    &lt;Day id="Tuesday"&gt;
      &lt;subject name="Digital Image Processing" session="2011" group="Alpha" teacher="Ali Javed" classroom="Class Room 2" time="11:30"&gt;
  
      &lt;/subject&gt;
  
    &lt;/Day&gt;
    &lt;Day id="Wednesday"&gt;
      &lt;subject name="Digital Image Processing" session="2011" group="Alpha" teacher="Ali Javed" classroom="Class Room 2" time="11:30"&gt;
  
      &lt;/subject&gt;
    &lt;/Day&gt;
    &lt;Day id="Thursday"&gt;
      &lt;subject name="Digital Image Processing" session="2011" group="Alpha" teacher="Ali Javed" classroom="Class Room 2" time="11:30"&gt;
  
      &lt;/subject&gt;
    &lt;/Day&gt;
    &lt;Day id="Friday"&gt;
      &lt;subject name="Digital Image Processing" session="2011" group="Alpha" teacher="Ali Javed" classroom="Class Room 2" time="11:30"&gt;
  
      &lt;/subject&gt;
    &lt;/Day&gt;
  
  &lt;/Root&gt;
  </code></pre>
  
  <p>I am reading and binding this file to a ListBox as follows</p>
  
  <pre><code>string TeachersXMLPath = "Teachers.xml";
              XDocument loadedData = XDocument.Load(TeachersXMLPath);
  
             var data = (from query in loadedData.Descendants("Day").Descendants("subject")
  
                         select new TimeTable
                         {
                             Teacher = (string)query.Attribute("teacher").Value,
                             Subject = (string)query.Attribute("name"),
                             Session = (string)query.Attribute("session"),
                             Group = (string)query.Attribute("group")
                         });
  
              listBox.ItemsSource = data;
  </code></pre>
  
  <p>Here is my TimeTable class:</p>
  
  <pre><code>public class TimeTable
  {
      string teacher;
      string subject;
      string session;
      string group;
      string time;
      string classroom;
  
      //Teacher Property
  
      public string Teacher
      {
          get{ return teacher;        }
          set{ teacher = value;        }
      }
      //Subject Property
  
      public string Subject
      {
          get { return subject; }
          set { subject = value; }
      }
      //Session Propert
  
      public string Session
      {
          get { return session; }
          set { session = value; }
      }
      //Group Property
  
      public string Group
      {
          get { return group; }
          set { group = value; }
      }
      //Time Property
  
      public string Time
      {
          get { return time; }
          set { time = value; }
      }
  
      public string Location
      {
          get { return classroom; }
          set { classroom = value; }
      }
  
  
  }
  </code></pre>
  
  <p>And here is my ListBox</p>
  
  <pre><code>&lt;ListBox x:Name="listBox" &gt;
                  &lt;ListBox.ItemTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;StackPanel Hold="teacher_detail_Hold" Margin="0,12,0,12"&gt;
  
                  &lt;Grid x:Name="LayoutList2" Background="BurlyWood"&gt;
                      &lt;Grid.RowDefinitions&gt;
                          &lt;RowDefinition Height="Auto"/&gt;
                          &lt;RowDefinition Height="Auto"/&gt;
                          &lt;RowDefinition Height="Auto"/&gt;
                          &lt;RowDefinition Height="Auto"/&gt;
                      &lt;/Grid.RowDefinitions&gt;
                      &lt;Grid.ColumnDefinitions&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                          &lt;ColumnDefinition Width="*"/&gt;
                      &lt;/Grid.ColumnDefinitions&gt;
  
                      &lt;TextBlock Text="{Binding Teacher}" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Center"/&gt;
                      &lt;TextBlock Name="subjectName" Text="{Binding Subject}" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Center"/&gt;
                      &lt;TextBlock Text="{Binding Session}" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" /&gt;
                      &lt;TextBlock Text="{Binding Group}" Style="{StaticResource PhoneTextNormalStyle}" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right"/&gt;
                                  &lt;Button Grid.Row="3" Grid.Column="1" 
                                          HorizontalAlignment="Right" 
                                          Click="delete_record"
                                          BorderThickness="0"&gt;
                                      &lt;Image Source="/Images/appbar.delete.rest.png"
                                             Width="75"
                                             Height="75"/&gt;
                                  &lt;/Button&gt;
                              &lt;/Grid&gt;
  
              &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ListBox.ItemTemplate&gt;
          &lt;/ListBox&gt;
  </code></pre>
  
  <p>It works good when displaying data.   </p>
  
  <p><strong>What I want is to bind ObservableCollection to ListBox</strong> so I would also be able to delete the selected item from list, when delete button clicked. </p>