void SetPage(Page page, bool isAnimated, bool isPopping) { if (_currentPage != null) { if (isPopping) { _currentPage.Cleanup(); } _container.Content = null; _currentPage.PropertyChanged -= OnCurrentPagePropertyChanged; } if (!isPopping) { _previousPage = _currentPage; } _currentPage = page; if (page == null) { return; } UpdateBackButton(); UpdateBackButtonTitle(); page.PropertyChanged += OnCurrentPagePropertyChanged; IVisualElementRenderer renderer = page.GetOrCreateRenderer(); UpdateTitleVisible(); UpdateTitleOnParents(); if (isAnimated && _transition == null) { _transition = new ContentThemeTransition(); _container.ContentTransitions = new TransitionCollection(); } if (!isAnimated && _transition != null) { _container.ContentTransitions.Remove(_transition); } else if (isAnimated && _container.ContentTransitions.Count == 0) { _container.ContentTransitions.Add(_transition); } _container.Content = renderer.ContainerElement; _container.DataContext = page; }
void SetPage(Page page, bool isAnimated, bool isPopping) { // Ignore if same page loaded if (page == _currentPage) { return; } // The new changes of this method, for :MasterDetails.Detail = exist page; performance if (_currentPage != null) { // Don't clean if RetainsRenderer is true if (isPopping && !page.GetRetainsRendererValue()) { IVisualElementRenderer previousRenderer = _currentPage.GetOrCreateRenderer(); _container.RemoveContent(previousRenderer.ContainerElement); _currentPage.Cleanup(); } _container.Content = null; _currentPage.PropertyChanged -= OnCurrentPagePropertyChanged; } if (!isPopping) { _previousPage = _currentPage; } _currentPage = page; if (page == null) { return; } UpdateBackButton(); UpdateBackButtonTitle(); page.PropertyChanged -= OnCurrentPagePropertyChanged; page.PropertyChanged += OnCurrentPagePropertyChanged; IVisualElementRenderer renderer = page.GetOrCreateRenderer(); if (isAnimated && _transition == null) { _transition = new ContentThemeTransition(); _container.ContentTransitions = new TransitionCollection(); } if (!isAnimated && _transition != null) { _container.ContentTransitions.Remove(_transition); } else if (isAnimated && _container.ContentTransitions.Count == 0) { _container.ContentTransitions.Add(_transition); } if (null != _previousPage) { ((IPageController)_previousPage)?.SendDisappearing(); } _container.Content = renderer.ContainerElement; if (_container.CheckContentIfExist(renderer.ContainerElement)) { ((IPageController)page)?.SendAppearing(); } _container.DataContext = page; UpdateTitleVisible(); UpdateTitleOnParents(); // update the inside pages size, if first page change size(because phone orientation changed), navigate to (exist) second page, the page size must resize again RefreshInsidePagesSize(); }