Ejemplo n.º 1
0
        void CleanUp(ScrollView scrollView, ScrollViewer scrollViewer)
        {
            if (Element != null)
            {
                Element.PropertyChanged -= OnContentElementPropertyChanged;
            }

            if (ContainerElement != null)
            {
                ContainerElement.LayoutUpdated -= SetInitialRtlPosition;
            }

            if (scrollView != null)
            {
                scrollView.ScrollToRequested -= OnScrollToRequested;
            }


            if (scrollViewer != null)
            {
                scrollViewer.ViewChanged -= OnViewChanged;
                if (scrollViewer.Content is FrameworkElement element)
                {
                    element.LayoutUpdated -= SetInitialRtlPosition;
                }
            }

            if (_currentView != null)
            {
                _currentView.Cleanup();
            }
        }
Ejemplo n.º 2
0
        void UpdateContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();
            }

            if (Control?.Content is FrameworkElement frameworkElement)
            {
                frameworkElement.LayoutUpdated -= SetInitialRtlPosition;
            }

            _currentView = Element.Content;

            IVisualElementRenderer renderer = null;

            if (_currentView != null)
            {
                renderer = _currentView.GetOrCreateRenderer();
            }

            Control.Content = renderer != null ? renderer.ContainerElement : null;

            UpdateMargins();
            if (renderer?.ContainerElement != null)
            {
                renderer.ContainerElement.LayoutUpdated += SetInitialRtlPosition;
            }
        }
Ejemplo n.º 3
0
        void UpdateContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();                 // cleanup old view
            }

            _currentView  = Element.Content;
            Control.Child = _currentView != null?Platform.GetOrCreateRenderer(_currentView).GetNativeElement() : null;
        }
Ejemplo n.º 4
0
        void UpdateContent()
        {
            _currentView?.Cleanup();     // cleanup old view

            _currentView  = Element.Content;
            Control.Child = _currentView != null?Platform.WPF.Platform.GetOrCreateRenderer(_currentView).GetNativeElement() : null;

            //Update vertical content Alignment
            if (Control.Child != null)
            {
                (Control.Child as FrameworkElement).VerticalAlignment = Element.Content.VerticalOptions.ToNativeVerticalAlignment();
            }
        }
Ejemplo n.º 5
0
        public Task<object> LoadContentAsync(Control parent, object oldContent, object newContent, CancellationToken cancellationToken)
        {
            VisualElement element = oldContent as VisualElement;
            if (element != null)
            {
                element.Cleanup(); // Cleanup old content
            }

            if (!global::Avalonia.Application.Current.CheckAccess())
                throw new InvalidOperationException("UIThreadRequired");

            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
            return Task.Factory.StartNew(() => LoadContent(parent, newContent), cancellationToken, TaskCreationOptions.None, scheduler);
        }
Ejemplo n.º 6
0
        void UpdateContent()
        {
            ContentPage page = Element as ContentPage;

            if (page != null)
            {
                if (_currentView != null)
                {
                    _currentView.Cleanup();                     // cleanup old view
                }

                _currentView    = page.Content;
                Control.Content = _currentView != null?Platform.GetOrCreateRenderer(_currentView).GetNativeElement() : null;
            }
        }
Ejemplo n.º 7
0
        void UpdateContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();                 // cleanup old view
            }

            _currentView = Element.Content;
            var render = Platform.GTK.Platform.GetRenderer(_currentView) ?? Platform.GTK.Platform.CreateRenderer(_currentView);

            Control.Child = _currentView != null ? render.Container : null;

            //Update vertical content Alignment
            if (Control.Child != null)
            {
            }
        }
Ejemplo n.º 8
0
        public Task <object> LoadContentAsync(FrameworkElement parent, object oldContent, object newContent, CancellationToken cancellationToken)
        {
            VisualElement element = oldContent as VisualElement;

            if (element != null)
            {
                element.Cleanup();                 // Cleanup old content
            }

            if (!System.Windows.Application.Current.Dispatcher.CheckAccess())
            {
                throw new InvalidOperationException("UIThreadRequired");
            }

            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            return(Task.Factory.StartNew(() => LoadContent(parent, newContent), cancellationToken, TaskCreationOptions.None, scheduler));
        }
Ejemplo n.º 9
0
        void LoadContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();
            }

            _currentView = Element.Content;

            IVisualElementRenderer renderer = null;

            if (_currentView != null)
            {
                renderer = _currentView.GetOrCreateRenderer();
            }

            Control.Content = renderer != null ? renderer.ContainerElement : null;

            UpdateMargins();
        }
Ejemplo n.º 10
0
        void UpdateContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();
            }

            if (Control?.Content is FrameworkElement oldElement)
            {
                oldElement.LayoutUpdated -= SetInitialRtlPosition;

                if (oldElement is IVisualElementRenderer oldRenderer &&
                    oldRenderer.Element is View oldContentView)
                {
                    oldContentView.PropertyChanged -= OnContentElementPropertyChanged;
                }
            }

            _currentView = Element.Content;

            IVisualElementRenderer renderer = null;

            if (_currentView != null)
            {
                renderer = _currentView.GetOrCreateRenderer();
            }

            Control.Content = renderer?.ContainerElement;

            UpdateContentMargins();
            if (renderer?.Element != null)
            {
                renderer.Element.PropertyChanged += OnContentElementPropertyChanged;
            }

            if (renderer?.ContainerElement != null)
            {
                renderer.ContainerElement.LayoutUpdated += SetInitialRtlPosition;
            }
        }
Ejemplo n.º 11
0
        private void LoadContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();
            }

            _currentView = Element.Content;

            IVisualElementRenderer renderer = null;

            if (_currentView != null)
            {
                renderer = _currentView.GetOrCreateRenderer();
                renderer.Container.Unparent();
            }

            if (renderer != null)
            {
                var content = renderer.Container;
                _viewPort.Add(content);
            }
        }
        void LoadContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();                 // cleanup old view
            }

            _currentView = Element.Content;

            if (_currentView != null)
            {
                /*
                 * Wrap Content in a DockPanel : The goal is to reduce ce Measure Cycle on scolling
                 */
                DockPanel dockPanel = new DockPanel();
                dockPanel.Children.Add(Platform.GetOrCreateRenderer(_currentView).GetNativeElement());
                Control.Content = dockPanel;
            }
            else
            {
                Control.Content = null;
            }
            UpdateMargins();
        }