I have a MVVM ViewModel on the UNO Platform. The ViewModel has an ObservableCollection:
public ObservableCollection<Location>? Locations { get; set; }
It is created in the constructor of the ViewModel:
this.Locations = new ObservableCollection<Location>();
The collection contents are initialized in the LoadData() method of the ViewModel as part of the Views codeBehind OnNavigatedTo(NavigationEventArgs e) event handler. The intialization is as follows:
List<Location> lst = await ApiClient.LocationGetAllByAccountId(MiscUtils.OrganizationId);
if (Locations != null)
{
foreach (Location l in lst)
{
Locations.Add(l);
}
}
When the view appears, the ComboBox is populated with the Locations, however when the app reacts to the ComboBox SelectedItem, the correct location has been selected, BUT I am finding that Locations is empty. This prevents me from adding, updating and deleting anything in the view. I never had this problem in WPF. Have I wired something wrong?
It is working now. I think I had a mixture of {Binding and {x:Bind in my code that was causing the problem.