0

I have a view model (an ObservableCollection list) set as ItemsSource for a ListBox. When I refresh this view model (get new data from network), should I set ItemsSource again, or just let it notify the ListBox ?

Which solution gains the most performance ?

P/S: Answer targeting Windows Phone 7 is prefered.

onmyway133
  • 45,645
  • 31
  • 257
  • 263

1 Answers1

1

If you have your ListBox`s ItemSource set to an ObservableCollection there is nothing you need to do. Just add/remove items to/from the ObservableCollection.

Igor Kulman
  • 16,211
  • 10
  • 57
  • 118
  • 1
    @Yamamoto i do not thinks so but there is absolutely no reason you should do it in your case – Igor Kulman Dec 05 '12 at 10:33
  • I see when setting ItemsSource, the ListBox take some longer to render than updating view model – onmyway133 Dec 05 '12 at 10:44
  • 1
    Erm, why do you want to set ItemsSource again?? It defeats the point of Silverlight's powerful binding functionality. I'd say definitely don't do it unless you need to specifically work around an issue. What Igor says above is correct. – geedubb Dec 05 '12 at 14:57