Before I explain my issue, consider the following object:
Character.cs
-> AnimationControlSettings.cs
.. -> UpControlType (string)
.. -> AvailableControlTypes (List<string>)
The relevant properties in my ViewModel:
Character SelectedCharacter
ObservableCollection<Character> Characters
I have a simple View where you select a character using a ComboBox. The ComboBox's SelectedItem is TwoWay-bound to the ViewModel's SelectedCharacter property. There are other textboxes/checkboxes (also two-way bound to various properties of SelectedCharacter) that maintain their values properly as I switch between Characters.
The problem exists in the ComboBox bound to the UpControlType property:
<ComboBox x:Name="lstUpControlTypes"
ItemsSource="{Binding Path=SelectedCharacter.AnimationControlSettings.AvailableControlTypes}"
SelectedItem="{Binding Path=SelectedCharacter.AnimationControlSettings.UpControlType, Mode=TwoWay}">
</ComboBox>
Initial values are displayed in this ComboBox correctly but as soon as I switch from CharacterA to CharacterB, CharacterA's UpControl property is set to NULL and I have no idea why.
Here is a barebones repro of this exact issue (VS2010, SL4): http://www.checksumlabs.com/source/TwoWayBindingWorkshop.zip
If you run that solution you'll see that the Name property persists as you switch Characters but the UpControlType value's getting set to NULL.
Am I missing something obvious here?