I would like a brief explanation of how to populate a combobox in MVVM pattern. The three parts, Model, View and ViewModel populated with the Database table.
Model:
class Racas : INotifyPropertyChanged
{
private int _cd_Raca;
private string _nm_Raca;
public int Cd_Raca
{
get { return _cd_Raca ; }
set
{
_cd_Raca = value;
NotifyOfPropertyChanged("Cd_Raca");
}
}
public string Nm_Raca
{
get { return _nm_Raca; }
set
{
_nm_Raca = value;
NotifyOfPropertyChanged("Nm_Raca");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyOfPropertyChanged(string propertyName)
{
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
View (XAML - WPF):
<ComboBox x:Name="dsCmbRaca" HorizontalAlignment="Left"
Margin="438,4,0,0" VerticalAlignment="Top" Width="94" Height="19"/>
I do not know how to implement the ViewModel so that it populates the ComboBox with the data of the Access table that are Cd_Raca and Nm_Raca