コード例 #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();
            }
        }
コード例 #2
0
ファイル: ScrollViewRenderer.cs プロジェクト: eroc218/xamarin
        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;
            }
        }
コード例 #3
0
        void UpdateContent()
        {
            if (_currentView != null)
            {
                _currentView.Cleanup();                 // cleanup old view
            }

            _currentView  = Element.Content;
            Control.Child = _currentView != null?Platform.GetOrCreateRenderer(_currentView).GetNativeElement() : null;
        }
コード例 #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();
            }
        }
コード例 #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);
        }
コード例 #6
0
ファイル: PageRenderer.cs プロジェクト: zmtzawqlp/maui
        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;
            }
        }
コード例 #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)
            {
            }
        }
コード例 #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));
        }
コード例 #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();
        }
コード例 #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;
            }
        }
コード例 #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);
            }
        }
コード例 #12
0
        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();
        }