I have a Silverlight control with my root ViewModel as a data source. ViewModel provides a list of maps, as well as a SelectedCard property, which is associated with a drop-down list at the top of the view. Then I have a view view that displays SelectedCard properties. My XAML looks like (reduced for simplicity):
<StackPanel Orientation="Vertical"> <ComboBox DisplayMemberPath="Name" ItemsSource="{Binding Path=Cards}" SelectedItem="{Binding Path=SelectedCard, Mode=TwoWay}" /> <TextBlock Text="{Binding Path=SelectedCard.Name}" /> <ListBox DisplayMemberPath="Name" ItemsSource="{Binding Path=SelectedCard.PendingTransactions}" /> </StackPanel>
I would expect TextBlock and ListBox to be updated whenever I select a new item in ComboBox, but this is not the case. I am sure that this is due to the fact that TextBlock and ListBox are actually tied to SelectedCard properties, so it listens for property change notifications for the properties of this object. But I would think that the data binding would be smart enough to recognize that the parent in the binding expression has changed and updated the entire binding.
It should be noted that the PendingTransactions property (associated with the ListBox) is loaded with a lazy load. So, the first time I select an item in ComboBox, I make an asynchronous call and load the list and user interface updates to display the information corresponding to the selected item. However, when I re-select an item, the user interface does not change!
For example, if my initial list contains three cards, I select the first card by default. The data binding attempts to access the PendingTransactions property in this map object and updates the ListBox correctly. If I select the second card in the list, the same thing happens, and I get the PendingTransactions list for this card. But, if I select the first card again, nothing changes in my user interface! Setting a breakpoint, I can confirm that the SelectedCard property is updated correctly.
How can I do this job?
source share