views:

159

answers:

2

Working with a listbox in windows phone 7 I am trying to make an async web service call then update the listbox on success.

The method that calls the webservice looks like this:

    public void GetReadingList(Action<ObservableCollection<MiniStoryViewModel>> success, Action<string> failure)

I am calling the method with this code:

        api.GetReadingList(
            (items) => Dispatcher.BeginInvoke(() => 
            {
                lsbNewest.ItemsSource = items;
            }),
            (error) =>
            {
                MessageBox.Show(error);
            });

Using this code nothing happens ui wise until I click or scroll on the listbox - then its contents is updated correctly. I am assuming that the code is not being run on the correct thread, how can i fix this?

+1  A: 

No errors in your code, you are right regarding the spec...

Try : flush the ItemsSource, then fill it with the items with addRange, or anything else. Check if your UI is automatically updated.

If not, create a basic silverlight app on Windows, and compare the two behaviours... maybe a bug ;=)

Echtelion
A: 

I solved the issue I was having by implementing inotifypropertychanged on my view model and raising the property changed event on the ui thread.

Luke Lowrey