private void SetupPage() { if (_visiblePageIndex != SelectedIndex && ItemsSource != null) { _currentView = (MycoView)ItemTemplate.CreateContent(); _currentView.BindingContext = ItemsSource[SelectedIndex]; _currentView.Parent = this; _currentView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height)); _currentView.TranslationX = 0; if (_nextView != null) { _nextView.Parent = null; _nextView = null; } _visiblePageIndex = SelectedIndex; Invalidate(); } else if (ItemsSource == null) { _currentView = null; _nextView = null; Invalidate(); } }
protected override void InternalLayout(Rectangle rectangle) { base.InternalLayout(rectangle); if (_currentView != null) { _currentView.Layout(new Rectangle(0, 0, rectangle.Width, rectangle.Height)); } if (_nextView != null) { _nextView.Layout(new Rectangle(0, 0, rectangle.Width, rectangle.Height)); } }
public async Task AnimateToPage(int index) { // really animate to new page ? if (_visiblePageIndex != index && _nextView == null && ItemsSource != null) { // get animation direction var translation = _visiblePageIndex < index ? Width : -Width; // indicate this is the one that is visible _visiblePageIndex = index; // save selected SelectedIndex = index; // get view to move to _nextView = (MycoView)ItemTemplate.CreateContent(); _nextView.BindingContext = ItemsSource[index]; _nextView.Parent = this; _nextView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height)); // setup the next view offscreen _nextView.TranslationX = translation; // view to set to once complete var targetView = _nextView; var oldView = _currentView; // animate new in, ol dout await Task.WhenAll(_nextView.TranslateTo(0, 0, 250, Easing.CubicInOut), _currentView.TranslateTo(-translation, 0, 250, Easing.CubicInOut)); // setup the current view _currentView = targetView; // null out old view oldView.Parent = null; oldView = null; // allow next animation _nextView = null; } }
private void SetupPage() { if (_visiblePageIndex != SelectedIndex && SelectedIndex >= 0 && SelectedIndex < Children.Count) { // only show the current view _currentView = Children[SelectedIndex]; _currentView.IsVisible = true; _currentView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height)); _currentView.TranslationX = 0; if (_nextView != null) { _nextView.IsVisible = false; _nextView = null; } _visiblePageIndex = SelectedIndex; Invalidate(); } }
public async Task AnimateToPage(int index) { // really animate to new page ? if (index >= 0 && index < Children.Count && _visiblePageIndex != index && _nextView == null) { // get animation direction var translation = _visiblePageIndex < index ? Width : -Width; // indicate this is the one that is visible _visiblePageIndex = index; // save selected SelectedIndex = index; // get view to move to _nextView = Children[index]; _nextView.IsVisible = true; _nextView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height)); // setup the next view offscreen _nextView.TranslationX = translation; // view to set to once complete var targetView = _nextView; var oldView = _currentView; // animate new in, ol dout await Task.WhenAll(_nextView.TranslateTo(0, 0, 250, Easing.CubicInOut), _currentView.TranslateTo(-translation, 0, 250, Easing.CubicInOut)); // setup the current view _currentView = targetView; // null out old view oldView.IsVisible = false; // allow next animation _nextView = null; } }