I had created a Listview of radiobutton, labels and a button binded using MVVM, at first time listview load well, but after execute CheckedChanged on group radiobutton, it make change on list datasource i call method that reload datasource but process is truncated and close app, on debugging it make error "Object reference not set to an instance of an object"
Steps to Reproduce
// MV class
namespace InspeccionesHS_App.ViewModels.CheckINAMViewModel.SetCheckINAMViewModel
{
public class RequestList1ViewModel: ViewModelBase
{
region Commands
public INavigation Navigation { get; set; }
public ICommand NextCommand => new AsyncCommand(NextFormAsync);
public Command LoadRequestsCommand => new AsyncCommand(LoadListRequests);
#endregion
private List<INAMRequestFormModel> _requestList = new List<INAMRequestFormModel>();
public List<INAMRequestFormModel> RequestList
{
get { return _requestList; }
set { SetProperty(ref _requestList, value); }
}
public RequestList1ViewModel(INAMModel ins)
{
LoadListRequests();
}
public async Task LoadListRequests()
{
if (IsBusy)
return;
IsBusy = true;
try
{ // method tha load a list datasource
var ListItemRequestForm = new List<INAMRequestFormModel>();
RequestList = getDataList(ListItemRequestForm);
}
catch (Exception ex)
{
await _dialogService.ShowError(ex.Message, "Error", "Aceptar", null);
IsBusy = false;
}
finally
{
IsBusy = false;
}
}
}
// I guess i make all implementation well, this is cs class from view page
public partial class RequestList1View : ContentPage
{
RequestList1ViewModel viewModel;
public RequestList1View(INAMModel _item)
{
InitializeComponent();
BindingContext = viewModel = new RequestList1ViewModel(_item);
viewModel.Navigation = Navigation;
NavigationPage.SetBackButtonTitle(this, string.Empty);
}
protected override async void OnAppearing()
{
base.OnAppearing();
}
async void OnCategoryCheck(object sender, CheckedChangedEventArgs e)
{
var b = (CheckBox)sender;
var reply = (b.IsChecked) ? "1" : "0";
await viewModel.UpdateRequestSelected(reply);
viewModel.LoadRequestsCommand.Execute(null);
}
void OnReplyRadioButtonCheckedChanged(object sender, CheckedChangedEventArgs e)
{
RadioButton button = sender as RadioButton;
var _request = button.BindingContext as INAMRequestFormModel;
_request.Reply = button.Value.ToString();
}
}
Expected Behavior
Reload List item and show changes on runtine after make checkedchanges
Actual Behavior
Basic Information
Version with issue:
Last known good version:
Platform Target Frameworks:
iOS:
Android:
UWP:
Android Support Library / AndroidX Version:
NuGet Packages:
Affected Devices:
Environment
Show/Hide Visual Studio info
```
```
Build Logs
System.NullReferenceException
Mensaje = Object reference not set to an instance of an object.
0xC in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:157,13 C#
0x6 in System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__7_0 at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021,49 C#
0xC in Android.App.SyncContext. at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36,19 C#
0xE in Java.Lang.Thread.RunnableImplementor.Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36,6 C#
0x8 in Java.Lang.IRunnableInvoker.n_Run at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Java.Lang.IRunnable.cs:84,4 C#
0x8 in Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22,5 C#
I had created a Listview of radiobutton, labels and a button binded using MVVM, at first time listview load well, but after execute CheckedChanged on group radiobutton, it make change on list datasource i call method that reload datasource but process is truncated and close app, on debugging it make error "Object reference not set to an instance of an object"
Steps to Reproduce
// MV class namespace InspeccionesHS_App.ViewModels.CheckINAMViewModel.SetCheckINAMViewModel { public class RequestList1ViewModel: ViewModelBase {
region Commands
}
// On view page i built
// I guess i make all implementation well, this is cs class from view page
public partial class RequestList1View : ContentPage { RequestList1ViewModel viewModel; public RequestList1View(INAMModel _item) { InitializeComponent(); BindingContext = viewModel = new RequestList1ViewModel(_item); viewModel.Navigation = Navigation; NavigationPage.SetBackButtonTitle(this, string.Empty); } protected override async void OnAppearing() { base.OnAppearing();
}
async void OnCategoryCheck(object sender, CheckedChangedEventArgs e) { var b = (CheckBox)sender;
Expected Behavior
Reload List item and show changes on runtine after make checkedchanges
Actual Behavior
Basic Information
Environment
Show/Hide Visual Studio info
``` ```Build Logs
System.NullReferenceException Mensaje = Object reference not set to an instance of an object.
Screenshots
Reproduction Link
Workaround