I’m probably missing something obvious due to the late hour.
I have a dictionary defined as such Dictionary<string,MyObject> where MyObject has a property bool IsFavoriate
Initially on page load I query my web service, and update the Dictionary with any new objects and save this in IsolatedStorage.
For the UI, I am binding the Dictionary to an ItemsControl where I have a checkbox:
<ItemsControl ItemsSource="{Binding Categories, Mode=TwoWay}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding Value.IsFavorite}" Content="{Binding Key}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
This binds fine. When I select a checkbox however, I want my Dictionary to update.
Do I perhaps need to have the properties in MyObject call RaisePropertyChanged? Maybe I’ll give that a shot for now.
You would need to implement the
INotifyPropertyChangedinterface on yourMyObjectclass and raise thePropertyChangedevent from yourIsFavoriteproperty setter in cases where the latter may be updated programmatically (after the initial population), and you want theIsCheckedproperty (and theCheckBox’s visual state) to be updated with your changes.In your case, you want updates to be propagated the other way round (from the
IsCheckedproperty toIsFavorite); that is typically accomplished by setting the binding toMode=TwoWay.P.S. I’m assuming you meant “When I
selectcheck a checkbox however, I want my Dictionary to update. ”