I am trying to populate the wpf combobox with list. I have two problems with it.
- It doesn't populate anything
- I am using Data Annotation for the validation. It doesn't set "Required" Error message in error display area.
Here is my XAML for the combobox:
<Label Target="{Binding ElementName=State}" Grid.Row="10" Grid.Column="0">State:</Label>
<ComboBox x:Name="State" Margin="10,0,0,10" Grid.Column="1" Grid.Row="10" ItemsSource="{Binding Path=States, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Validation.Error="Validation_Error" SelectedValue="{Binding Path=FamilyMember.State}"/>
<TextBlock Grid.Column="2" Grid.Row="10" Style="{StaticResource TextBlockStyle}" Text="{Binding (Validation.Errors)[0].ErrorContent, ElementName=State}" Margin="10,0,0,10"/>
Here is my partial viewmodel where I am declaring and populating my States object.
Property in ViewModel
public ObservableCollection<string> States;
Constructor:
States = new ObservableCollection<string>();
States.Add("One");
States.Add("Two");
States.Add("Three");
States.Add("Four");
States.Add("Five");
Here is the proof from my Debug that I am getting states correctly to a view.

And another problem is that my data annotation error is not working
Here is my partial Model:

It is working for other fields without any problems as seen below:

public ObservableCollection<string> States;-- That's not a property. It's a field. You can't bind to it. You can only bind to properties. You need to make a it a property by giving it{ get; set; }. Second, your "proof" that you're "getting states correctly to a view" doesn't make any sense to me; what do you mean when you say "view"?UpdateSourceTrigger=PropertyChangedandMode=TwoWayon the ItemsSource Binding is pointless, as the source is never updated by the Binding.