示例#1
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.OpenRequested  -= OnOpenRequested;
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is ScrollView scrollView)
                    {
                        scrollView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is ListView listView)
                    {
                        listView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is System.Maui.CollectionView collectionView)
                    {
                        collectionView.Scrolled -= OnParentScrolled;
                    }
                }

                if (_contentView != null)
                {
                    _contentView.RemoveFromParent();
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.RemoveFromParent();
                    _actionView.Dispose();
                    _actionView = null;
                }

                if (_initialPoint != null)
                {
                    _initialPoint.Dispose();
                    _initialPoint = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_detector != null)
                {
                    _detector.Dispose();
                    _detector = null;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is ScrollView scrollView)
                    {
                        scrollView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is ListView listView)
                    {
                        listView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is Xamarin.Forms.CollectionView collectionView)
                    {
                        collectionView.Scrolled -= OnParentScrolled;
                    }
                }

                if (_contentView != null)
                {
                    _contentView.RemoveFromParent();
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.RemoveFromParent();
                    _actionView.Dispose();
                    _actionView = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_detector != null)
                {
                    _detector.Dispose();
                    _detector = null;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is AbsListView listView)
                    {
                        listView.ScrollStateChanged += OnParentScrollStateChanged;
                    }
                    else
                    {
                        _scrollParent.ScrollChange -= OnParentScrollChange;
                    }

                    _scrollParent = null;
                }

                if (_contentView != null)
                {
                    _contentView.RemoveFromParent();
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.RemoveFromParent();
                    _actionView.Dispose();
                    _actionView = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }