Example #1
0
        public void SetElement(VisualElement element)
        {
            ScrollView oldElement = _view;

            _view = (ScrollView)element;

            if (oldElement != null)
            {
                oldElement.PropertyChanged -= HandlePropertyChanged;
                oldElement.LayoutChanged   -= HandleLayoutChanged;

                ((IScrollViewController)oldElement).ScrollToRequested -= OnScrollToRequested;
            }
            if (element != null)
            {
                OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));

                if (_container == null)
                {
                    Tracker    = new VisualElementTracker(this);
                    _container = new ScrollViewContainer(_view, Context);
                }

                _view.PropertyChanged += HandlePropertyChanged;
                _view.LayoutChanged   += HandleLayoutChanged;

                Controller.ScrollToRequested += OnScrollToRequested;

                LoadContent();
                UpdateBackgroundColor();
                UpdateOrientation();
                UpdateIsEnabled();
                UpdateHorizontalScrollBarVisibility();
                UpdateVerticalScrollBarVisibility();
                UpdateFlowDirection();

                element.SendViewInitialized(this);

                if (!string.IsNullOrEmpty(element.AutomationId))
                {
                    ContentDescription = element.AutomationId;
                }
            }

            EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);
        }
Example #2
0
        protected override void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                SetElement(null);
                Tracker?.Dispose();
                Tracker = null;
                RemoveAllViews();
                _container?.Dispose();
                _container = null;
            }

            base.Dispose(disposing);
        }