title: WP7 LongListSelector ItemsSource Databinding Issue
body: <p>I am trying to implement the LongListSelector in a new WP7 application.  The LongListSelector exists in a UserControl bound to an MVVMLight view model.  I get the following error when I try to load the UserControl:</p>
  
  <p>System.ArgumentException was unhandled
    Message=The parameter is incorrect. 
    StackTrace:
         at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
         at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, Double d)
         at System.Windows.DependencyObject.SetValue(DependencyProperty property, Double d)
         at System.Windows.FrameworkElement.set_Width(Double value)
         at Microsoft.Phone.Controls.LongListSelector.GetAndAddElementFor(ItemTuple tuple)
         at Microsoft.Phone.Controls.LongListSelector.Balance()
         at Microsoft.Phone.Controls.LongListSelector.EnsureData()
         at Microsoft.Phone.Controls.LongListSelector.LongListSelector_Loaded(Object sender, RoutedEventArgs e)
         at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
         at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)</p>
  
  <p>I have been able to narrow down the problem to the Items in my binding source, however I cannot see what the problem is.  </p>
  
  <p>Here is the XAML from my UserControl:</p>
  
  <pre><code>&lt;UserControl x:Class="BTT.PinPointTime.WinPhone.Views.TaskSelectionControl"
           xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           FontFamily="{StaticResource PhoneFontFamilyNormal}"
           FontSize="{StaticResource PhoneFontSizeNormal}"
           Foreground="{StaticResource PhoneForegroundBrush}"
           d:DesignHeight="480"
           d:DesignWidth="480"
           DataContext="{Binding Source={StaticResource Locator}, Path=TaskSelection}"&gt;
  
  &lt;UserControl.Resources&gt;
      &lt;DataTemplate x:Key="itemTemplate"&gt;
          &lt;StackPanel Grid.Column="1"
                      VerticalAlignment="Top"&gt;
              &lt;TextBlock Text="{Binding Name}"
                         FontSize="26"
                         Margin="12,-12,12,6" /&gt;
          &lt;/StackPanel&gt;
      &lt;/DataTemplate&gt;
  
      &lt;DataTemplate x:Key="groupHeaderTemplate"&gt;
          &lt;Border Background="YellowGreen"
                  Margin="6"&gt;
              &lt;TextBlock Text="{Binding Title}" /&gt;
          &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  
      &lt;DataTemplate x:Key="groupItemTemplate"&gt;
          &lt;Border Background="Pink"
                  Margin="6"&gt;
              &lt;TextBlock Text="{Binding Title}" /&gt;
          &lt;/Border&gt;
      &lt;/DataTemplate&gt;
  &lt;/UserControl.Resources&gt;
  
  &lt;Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}"&gt;
      &lt;Grid x:Name="ContentPanel"
            Grid.Row="1"
            Margin="12,0,12,0"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="*" /&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;toolkit:LongListSelector Grid.Row="1"
                                    Background="Red"
                                    ItemsSource="{Binding GroupedTasks}"
                                    GroupItemTemplate="{StaticResource groupItemTemplate}"
                                    ItemTemplate="{StaticResource itemTemplate}"
                                    GroupHeaderTemplate="{StaticResource groupHeaderTemplate}"&gt;
              &lt;toolkit:LongListSelector.GroupItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;toolkit:WrapPanel /&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/toolkit:LongListSelector.GroupItemsPanel&gt;
          &lt;/toolkit:LongListSelector&gt;
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is the code that I am using to populate the GroupedTasks property in my view model (it is declared as ObservableCollection> GroupedTasks):</p>
  
  <pre><code> private void LoadData()
      {
          if (App.Database.Query&lt;Task, Guid&gt;().Count() &gt; 0)
          {
              GroupedTasks.Clear();
  
              var tasks = (from t in App.Database.Query&lt;Task, Guid&gt;().ToList() select t.LazyValue.Value);
  
              var groupedTasks = from t in tasks
                                 group t by t.FullParentString into t1
                                 orderby t1.Key
                                 //select new Group&lt;Task&gt;(t1.Key, t1);
                                 select new Group&lt;Task&gt;(t1.Key);
  
              foreach (Group&lt;Task&gt; o in groupedTasks)
              {
                  GroupedTasks.Add(o);
              }
  
              foreach (Group&lt;Task&gt; g in GroupedTasks)
              {
                  var currentTasks = (from t in tasks where t.FullParentString == g.Title select t);
  
                  foreach (Task t in currentTasks)
                  {
                      g.Add(t);
                  }
              }
          }
  
          _isDataLoaded = true;
      }
  </code></pre>
  
  <p>and finally here is the declaration of my Group class:</p>
  
  <pre><code>public class Group&lt;T&gt; : ObservableCollection&lt;T&gt;
  {
  
      public string Title
      {
          get;
          set;
      }
  
      public bool HasItems
      {
          get
          {
              return Count != 0;
          }
          private set
          {
          }
      }
  
      public Group(string name)
      {
          this.Title = name;
      }
  }
  </code></pre>
  
  <p>I did originally implement this as a simple IEnumerable as per the turorial on Windows Phone Geek.  However that gave me exactly the same error.</p>
  
  <p>I do not get any binding errors, however there is nothing that I can see that will enable me to track down the source of the problem.</p>