2
I would like a brief explanation of how to fill a MVVM standard combobox. The three parts, Model, View and Viewmodel filled with the table of the Database.
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 don’t know how to implement Viewmodel so that it fills the Combobox with the Access table data that are Cd_raca and Nm_raca
Try to implement or if you already have some pole code so we can help.
– rubStackOverflow
Enter the code
– Samuel Monteiro