::EDIT note::
I have completely rewritten this question and it's title for simplification (my entity set names and properties were much more difficult to follow than this analogous scenario).
::/EDIT note::
I have really been struggling to find the "missing navigational link" between what I am able to see and save back to my entity Context
from a DataGridComboBoxColumn.
MY ENTITY SETS:
My VIEW: A DataGrid bound to a "Classes" Entity Set.
It has two columns:
- A DataGridComboBoxColumn (which displays InstructorNames for each class)
- A DataGridTextColumn (which diplays classes by Name)
<DataGrid x:Name="DataGrid1" DockPanel.Dock="Top" Background="Transparent"
ItemsSource="{Binding ClassesObservableCollection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridComboBoxColumn Width="220"
Header="Instructor"
SelectedValueBinding="{Binding InstructorID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValuePath="InstructorID"
DisplayMemberPath="InstructorName">
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=DataContext.InstructorsObservableCollection}"/>
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Path=DataContext.InstructorsObservableCollection}"/>
</Style>
</DataGridComboBoxColumn.ElementStyle>
</DataGridComboBoxColumn>
That all was painful to get through, and thankfully it works quite nicely. Updates work using the DataGridComboBoxColumn selection, but NEW ROWS DO NOT SAVE WITH .SaveChanges()
!
Please help me find what I am missing.
Could it perhaps be in this mysterious SelectedItemBinding Property, which I could never get to send change notifications using the backing property on my viewmodel?
Do I need to explicitly tell my bound Classes entity how to save each property? (This doesn't seem reasonable...it should be taken care of with xaml binding it seems.)
Thank you for reading!