title: How to group ListBox items by date
body: <p>Im trying to do simple task app. I have tasks with due date and I want to display it like this:</p>
  
  <p><img src="https://i.stack.imgur.com/VsKg8.png" alt="this is what I want"></p>
  
  <p>I know how to display data in listbox, but I dont know how to group them by DueDate and display that DueDates like headers (as it is in the image below).</p>
  
  <p>This is my XML file with tasks (tasks.xml):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Tasks&gt;
    &lt;Task&gt;
      &lt;Name&gt;first task&lt;/Name&gt;
      &lt;DueDate&gt;05/03/2013 00:00:00&lt;/DueDate&gt;
      &lt;Created&gt;03/27/2013 01:24:08&lt;/Created&gt;
    &lt;/Task&gt;
    &lt;Task&gt;
      &lt;Name&gt;second task&lt;/Name&gt;
      &lt;DueDate&gt;05/17/2013 00:00:00&lt;/DueDate&gt;
      &lt;Created&gt;03/27/2013 01:24:19&lt;/Created&gt;
    &lt;/Task&gt;
    &lt;Task&gt;
      &lt;Name&gt;third task&lt;/Name&gt;
      &lt;DueDate&gt;05/17/2013 00:00:00&lt;/DueDate&gt;
      &lt;Created&gt;03/27/2013 01:24:38&lt;/Created&gt;
    &lt;/Task&gt;
  &lt;/Tasks&gt;
  </code></pre>
  
  <p>And this is my data model (MainViewModel.cs):</p>
  
  <pre><code>public class MainViewModel : INotifyPropertyChanged
  {
      public ObservableCollection&lt;Task&gt; Tasks { get; private set; }
  
      public MainViewModel()
      {
          this.Tasks = new ObservableCollection&lt;Task&gt;();
      }
  
      public bool IsDataLoaded
      {
          get;
          private set;
      }
  
      public void LoadData()
      {
          try
          {
              Tasks.Clear();
  
              var file = IsolatedStorageFile.GetUserStoreForApplication();
              XElement xElem;
  
              using (IsolatedStorageFileStream read = file.OpenFile("tasks.xml", FileMode.Open))
              {
                  xElem = XElement.Load(read);
              }
  
              var tasks = from task in xElem.Elements("Task")
                          select task;
  
              foreach (XElement xElemItem in tasks)
              {
                  string dueDate = "";
                  DateTime convertedDate;
  
                  if (DateTime.TryParse(xElemItem.Element("DueDate").Value.ToString(), out convertedDate))
                  {
                      dueDate = convertedDate.ToShortDateString();
                  }
  
                  Tasks.Add(new Task
                  {
                      Name = xElemItem.Element("Name").Value.ToString(),
                      DueDate = dueDate,
                      Created = xElemItem.Element("Created").Value.ToString()
                  });
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
  
          this.IsDataLoaded = true;
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
      private void NotifyPropertyChanged(String propertyName)
      {
          PropertyChangedEventHandler handler = PropertyChanged;
          if (null != handler)
          {
              handler(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  }
  </code></pre>
  
  <p>How can I do it?</p>