title: WP7 Binding Listbox to WCF result
body: <p>I have a WCF call that returns a list of objects.</p>
  
  <p>I've created a WP7 Silverlight Pivot application and modified the MainViewModel to load data from my WCF service, the LoadData method now looks like this</p>
  
  <pre><code>public ObservableCollection&lt;Standing&gt; Items { get; private set; }
  
  public void LoadData()
  {
      var c = new WS.WSClient();
      c.GetStandingsCompleted += GetStandingsCompleted;
      c.GetStandingsAsync();            
  }
  
  void GetStandingsCompleted(object sender, GetStandingsCompletedEventArgs e)
  {
      Items = e.Result;
      this.IsDataLoaded = true;
  }
  </code></pre>
  
  <p>This runs and if I put a break point on the completed event I can see it ran successfully and my Items collection now has 50 odd items. However the listbox in the UI doesnt display these. </p>
  
  <p>If I add the following line to the bottom of my LoadData method then I see 1 item appear in the listbx on the UI</p>
  
  <pre><code>Items.Add(new Standing(){Team="Test"});
  </code></pre>
  
  <p>This proves the bindings are correct but it seems that because of the delay in the Asynch WCF call the UI doesn't update.</p>
  
  <p>For reference I've updates the MainPage.xaml listbox to bind to the Team property on my Standing object</p>
  
  <pre><code>&lt;ListBox x:Name="FirstListBox" Margin="0,0,-12,0" ItemsSource="{Binding Items}"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
            &lt;StackPanel Margin="0,0,0,17" Width="432"&gt;
                  &lt;TextBlock Text="{Binding Team}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/&gt;
                  &lt;TextBlock Text="{Binding Team}" TextWrapping="Wrap" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}"/&gt;
            &lt;/StackPanel&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Any ideas on what I'm doing wrong?</p>
  
  <p>Thanks</p>