开发者

Silverlight listbox itemsource change not updating list

开发者 https://www.devze.com 2023-01-08 14:14 出处:网络
Working with a listbox in windows phone 7 I am trying to make an async web service call then update the listbox on success.

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;
            }),
         开发者_JS百科   (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?


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 ;=)


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

0

精彩评论

暂无评论...
验证码 换一张
取 消