I am trying to display the contents of a table in a combobox.
I am using the MVVM template and in my viewmodel class, if I write this, it works:
private IEnumerable<EventType> _eventTypes;
public ManageProfileModel()
{
_referenceData = new ReferenceDataContext();
_referenceData.Load(_referenceData.GetEventTypesQuery(), false);
_eventTypes = _referenceData.EventTypes;
}
Similarly, a drop-down field displays data.
However, I want _eventTypes to be List:
private List<EventType> _eventTypes;
But if I write this:
public ManageProfileModel()
{
_referenceData = new ReferenceDataContext();
_referenceData.Load(_referenceData.GetEventTypesQuery(), false);
_eventTypes = _referenceData.EventTypes.ToList();
}
then the combo box is empty. What is wrong with this?
I want to use the List because I want to be able to add and delete data in the list.
Sincerely.
source
share