I have a question, is it correct to initialize a property full
in ViewModel
as follows?
public class MainViewModel : ViewModelBase
{
private ObservableCollection<Driver> _drivers = new ObservableCollection<Driver>();
public ObservableCollection<Driver> Drivers
{
get { return _drivers; }
set { _drivers = value;
RaisePropertyChanged();
}
}
}
Is it correct? Is it a bad practice? or should it be done in another way? My question arises since I was trying to fill that collection with a method that initialized the field but the changes were not reflected in the XAML
that is linked to the property Drivers
, only instantiating the field _drivers
in this way I got it to work.
Thanks.