I’m using Silverlight to develop, and right now I’d like to bind my ComboBox to an ObservableCollection. However, the ObservableCollection is inside my SelectedItem, so I’m not sure whether it’s able to work out as I expected.
I’ve tried ItemsSource={Binding SelectedItem.SourceList} and ItemsSource={Binding Path=SelectedItem.SourceList}, but both ways don’t give the output I want.
If anyone has any idea… many thanks!
EDIT: The ObservableCollection inside the object is the BerthList. The items in this BerthList are constrained by the user’s previous choice of Port. If I were to place my ObservableCollection of Berths inside the ViewModel, then the problem arises.
Let’s say Port A has Berth A and B; Port B has Berth C and D. If I select a Port A/Berth A combination for my first item (let’s just call this item a timesheet), then when I go to the next item and select Port B, bam, my Berth selection for my first item disappears, because the Berth List no longer has Port A.
I wonder if this helps explain things…
To have a SelectedItem in your combobox, you need to have the ItemSource first.
It seems your approach to the problem is not correct.
Try to find an approach where the ObservableCollection has nothing to do with your SelectedItem.