"Jeremy" <je***********@ninprodata.comwrote in message
news:ef**************@TK2MSFTNGP03.phx.gbl...
Chris, thanks for the pointer. Dr. WPF is a great site.
I've got this working, except for re-populating the itemsSource.
I have a list of objects which I use to populate the source. User picks
one and I populate some textboxes. When the user makes a change and saves
it to a database, I create a new List<T>, load it from the database and
assign it to itemsSource. I do the reload after save because I don't want
to have to detect whether the user added a new item or merely edited an
existing one.
The problem is, after saving, the dropdown now has only 2 items showing,
but the actual itemsSource list has 4 items.
I figure there is some kind of reset that needs to be done, but haven't
found a method yet.
Any ideas?
That sounds very strange. Normally changing the ItemsSource is all that's
needed. A couple of ideas:
- I assume you first populated the list using the ItemsSource rather than
setting the Items property. If not I'm not sure what happens if both Items
and ItemsSource are set, but I'd suggest setting Items to null first.
- Is it definitely a NEW List<Tthat you are assigning to ItemsSource
(rather than re-using the same List<Tbut clearing and reloading the items
in the list)? If you are re-using the same List<Tobject then setting
ItemsSource to null and then back to the List should work.
If you haven't done so already, it might be worth looking at
ObservableCollection<Tinstead of List<T>, since that will automatically
notify any controls bound to it of changes to the items in the collection.
Good luck!
Chris