My MainView.xaml contains my SmartForm View:
<Grid Margin="10">
<views:SmartForm/>
</Grid>
the SmartForm view loads an ItemsControl
<Grid Margin="10">
<ItemsControl
ItemsSource="{Binding DataTypeViews}"/>
</Grid>
which is an ObservableCollection of DataTypeViews:
List<FormField> formFields = new List<FormField>();
formFields.Add(new FormField { IdCode = "firstName", Label = "First Name", Value = "Jim" });
formFields.Add(new FormField { IdCode = "lastName", Label = "Last Name", Value = "Smith" });
formFields.Add(new FormField { IdCode = "address1", Label = "Address 1", Value = "123 North Ashton Rd." });
formFields.Add(new FormField { IdCode = "address2", Label = "Address 2", Value = "Box 23434" });
formFields.Add(new FormField { IdCode = "city", Label = "City", Value = "New Haven" });
formFields.Add(new FormField { IdCode = "state", Label = "State", Value = "NM" });
formFields.Add(new FormField { IdCode = "zip", Label = "Zip Code", Value = "34234" });
foreach (FormField formField in formFields)
{
DataTypeView dtv = new DataTypeView();
DataTypeViewModel dtvm = new DataTypeViewModel(formField);
dtv.DataContext = dtvm;
DataTypeViews.Add(dtv);
}
and each view shows the label and textbox which builds a form:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="90"/>
<ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0">
<TextBlock Text="{Binding Label}" FontSize="14"/>
<TextBlock Text=": " FontSize="14"/>
</StackPanel>
<TextBox Grid.Column="1" Text="{Binding Value}" FontSize="12"/>
</Grid>
How do I bubble the Textbox changes that happen in DataTypeViewModel up into SmartFormViewModel?
Or in other words: If ViewModel A contains a collection of ViewModel B, and a change happens in a ViewModel B, how can I bubble that change up to ViewModel A?