combobox itemssource binding issue
In a MVVM WPF application, I have a master-detail View that is used to manage Alarms. In the AlarmDetails View I have several properties that are set through ComboBox controls. One of those is the Alarm's Source, and those sources can be changed in another View (SourcesView), thus changing the combobox content in the AlarmDetailsView.
The way the data flows is relatively straightforward
I am at a loss with this, I have been poundering this for a while.
Anyone have an idea? Any debugging suggestions?
Thanks,
Alex
EDIT: The ComboBox that does not update is located within the AlarmDetailsView, which means that it is used to set a property of the Alarm object (its Source, namely). Hope this helps.
EDIT 2: In addition to the answer below, another solution was to use an ObservableCollection instead of a List. For some reason, raising a PropertyChange event on the List (as described above) triggered the ComboBox to refresh its ItemsSource, but not to add the new items to its drop-down. Using the ObservableCollection, there is not need to raise the propertychange event since it manages it all by itself.
** EDIT **
Ugly solution but worked for me if someone has a better solution please share :)
Emptied the collection, notified the GUI, added the real collection notified to gui
Try using CollectionViewSource to handle your Master/Detail bindings.
Heres an example
<Window.Resources>
<CollectionViewSource x:Key="data" Source="{Binding}" />
<Window.Resources>
DataContext="{Binding CurrentItem, Source={StaticResource data}}"
链接地址: http://www.djcxy.com/p/41258.html
上一篇: Silverlight组合框强制重新选择SelectedItem
下一篇: 组合框itemssource绑定问题