This repository has been archived by the owner on May 1, 2024. It is now read-only.
Cannot reload Listview datasource more than once, app close after error, Object reference not set to an instance of an object #15852
Labels
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 _requestList = new List();
public List 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();
RequestList = getDataList(ListItemRequestForm);
}
catch (Exception ex)
{
await _dialogService.ShowError(ex.Message, "Error", "Aceptar", null);
IsBusy = false;
}
finally
{
IsBusy = false;
}
}
}
}
// 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
The text was updated successfully, but these errors were encountered: