private bool DisposeDataSource() { if (DataSource != null && this._isDisposing == false) { DataSource.OnSwipe -= OnSwipe; DataSource.OnScrollEvent -= OnScrollEvent; DataSource.Dispose(); DataSource = null; this.Control.Source = null; return(true); } return(false); }
protected override void OnElementChanged(ElementChangedEventArgs <ListView> e) { base.OnElementChanged(e); var customListview = Element as CustomListview; if (customListview == null) { return; } if (this.Control != null && this._isDisposing == false && this.Element != null) { this.Control.MultipleTouchEnabled = true; DataSource = new WrapperSource(Control.Source, Control, 55); DataSource._LastYPosition = 0; //DataSource._RemoveListViewInset = Source.RemoveInset; Control.Source = DataSource; DataSource.OnSwipe += OnSwipe; DataSource.OnScrollEvent += OnScrollEvent; } if (Control != null) { var tvDelegate = new TableViewDelegate(); Control.Delegate = tvDelegate; tvDelegate.OnScrolled += TvDelegate_OnScrolled; tvDelegate.OnDecelerationStarted += (s, ev) => { CustomListview.OnScrollStateChanged(customListview, new ScrollStateChangedEventArgs(ScrollStateChangedEventArgs.ScrollState.Running)); }; tvDelegate.OnDecelerationEnded += (s, ev) => { CustomListview.OnScrollStateChanged(customListview, new ScrollStateChangedEventArgs(ScrollStateChangedEventArgs.ScrollState.Idle)); }; tvDelegate.OnRowSelected += (s, ev) => { var index = s as NSIndexPath; CustomListview.OnItemTappedIOS(customListview, new ItemTappedIOSEventArgs(index.Row)); }; } }