Open pardont opened 5 years ago
Yeah its quite possible you have uncovered something. Your particular scenario is not something I would have tested significantly.
These suggestions will probably not make a difference but no harm in tryting since it shouldn't take too long to implement..
So basically in your TestBindingPage class declare a new
public partial class TestBindingPage : ContentPage, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public _ObservableCollection<TimeModel> DataContext { get; set; } new _ObservableCollection<TimeModel>();
/// <summary>
/// switch gridview's ItemsSource
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Clicked(object sender, EventArgs e)
{
lock (lockHelper)
{
_sourceIndex = _sourceIndex == 0 ? 1 : 0;
DataContext.ReplaceRange(source[_sourceIndex]);
}
}
It seems the viewcell's BindingContext not remove when gridview.ItemsSource reset.
I have one page contains one gridview show plu info, some category button to switch gridview's ItemsSource, and a timer to sync plu info from db. But when I switch category serveral times(5-10 times), the app crashed. exception is: `Unhandled Exception:
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'Xamarin.Forms.Platform.Android.FormsTextView'.`
Attached is the page code, please help, Thanks.
PageCode.zip