I have a common issue which I will explain one specific event
The comon exception is :
"System.NullReferenceException: Object reference not set to an instance of an object.
at Syncfusion.Android.ComboBox.SfComboBox.Handle_CollectionChanged
(System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
[0x00000] in <6d1ab70763e74d7cbbdad401f96975a6>:0 at (wrapper delegate-invoke)
<Module>.invoke_void_object_NotifyCollectionChangedEventArgs(object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged
(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00018] in
<2b1467cde5f6428d89ddadc0df922c3d>:0 at System.
Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged
(System.Collections.Specialized.NotifyCollectionChangedAction action, System.Object item, System.Int32 index)
[0x00009] in <2b1467cde5f6428d89ddadc0df922c3d>:0
at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x0001a] in <2b1467cde5f6428d89ddadc0df922c3d>:0
at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00020] in <46c2fa109b574c7ea6739f9fe2350976>:0
.. then ref my code lines"
this happens after the VM and page is visable if I update the data inside the Bound Observable collection
In this situation I have two SfComboBoxes , I load the first combo box with a list of availible programs from the database
when the user selects a program I load in the next comboBox a list of Term Lengths, "1 Year","2 Years", etc....
private ObservableCollection<string> _programCodes;
public ObservableCollection<string> ProgramCodes{ get { return _programCodes; }set{SetProperty(ref _programCodes, value);}}
private ValidatableObject<string> _programCode;
public ValidatableObject<string> SelectedProgramCode{get { return _selectedProgramCode; }set{if (_selectedProgramCode != value){SetProperty(ref _selectedProgramCode, value);}}}
private ObservableCollection<ProgramTerms> _Terms;
public ObservableCollection<ProgramTerms> Terms {get { return _terms;} set { SetProperty(ref _terms, value); } }
I have Added a Behavior in the Xaml
<behaviors:EventToCommandBehavior EventName="SelectionChanged" Command="{Binding GasProgramCodeSelectedCommand}" />
which is bound to this command in the ViewModel
public ICommand ProgramCodeSelectedCommand => new Command(() => {
ShowVersionCode = !string.IsNullOrWhiteSpace(_selectedProgramCode.Value);
SetTermsAvailible(GasTerms, _selectedProgramCode.Value, 1, _selectedCustomerType.Value.ID);
});
private void SetTermsAvailible(ObservableCollection<ProgramTerms> refTerms, string programCode, int serviceTypeId, int customerTypeId)
{
...
...
.. Stuff that doesn't break
//When I get here this is where the exception blows up.
foreach (var term in newTermsList)
{
refTerms.Add(term);
}
}