I edit, thanks for the help @ Brian593.
I have the first drop-down and it detects me when I select another from the list, now I need the second drop-down to change its items depending on the first, I leave the code below:
public class DatosBaseViewModel : INotifyPropertyChanged
{
...
#region Properties
public ObservableCollection<UnidadObra> UnidadesObra { get; set; }
public ObservableCollection<UnidadObraGrupo> UnidadesObraGrupo { get; set; }
public UnidadObraGrupo SelectedUnidadObraGrupo { get; set; }
int unidadObraGrupoSelectedIndex;
public int UnidadObraGrupoSelectedIndex
{
get
{
return unidadObraGrupoSelectedIndex;
}
set
{
if (unidadObraGrupoSelectedIndex != value)
{
unidadObraGrupoSelectedIndex = value;
// trigger some action to take such as updating other labels or fields
OnPropertyChanged(nameof(UnidadObraGrupoSelectedIndex));
SelectedUnidadObraGrupo = UnidadesObraGrupo[UnidadObraGrupoSelectedIndex];
}
UnidadesObra = new ObservableCollection<UnidadObra>(UnidadesObraTotal.Where(l => l.Grupo == SelectedUnidadObraGrupo.Cod));
}
}
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
#endregion
...
To be more specific, the idea is that the UnidadObra drop-down will change depending on what has been selected in UnidadObraGrupo .
Thanks for your help.