void Gesture_OnAction(BaseGestureRecognizer recgonizer, GestureRecognizerState state) { if (recgonizer.View != MediaItemsListView) { return; } var panGesture = recgonizer as PanGestureRecognizer; Point translation = panGesture.GetTranslationInView(MainLayout); Point velocity = panGesture.GetVelocityInView(MainLayout); panGesture.SetTranslationInView(new Point(0, 0), MainLayout); switch (panGesture.State) { case GestureRecognizerState.Began: // MediaItemsListView.IsEnabled = false; break; case GestureRecognizerState.Changed: var newY = _currentGridY + translation.Y; newY = Math.Max(0, newY); newY = Math.Min(400, newY); Debug.WriteLine("newY {0} _currentGridY {1} _scrollPosition{2}", newY, _currentGridY, _scrollPosition); bool willMoveList = false; if (newY != _currentGridY) { willMoveList = _currentGridY > 0 || _scrollPosition <= 0 && newY > 0 && newY < Height - 100; if (willMoveList) { _currentGridY = newY; var bounds = MediaItemsListView.Bounds; bounds.Y = _currentGridY; MediaItemsListView.Layout(bounds); } MediaItemsListView.IsScrollEnabled = !willMoveList; } else { MediaItemsListView.IsScrollEnabled = true; Debug.WriteLine("no move " + MediaItemsListView.IsScrollEnabled); } break; case GestureRecognizerState.Cancelled: case GestureRecognizerState.Ended: case GestureRecognizerState.Failed: MediaItemsListView.IsScrollEnabled = true; if (_currentGridY != 0 && _currentGridY != 400) { _currentGridY = _currentGridY > 200 ? 400 : 0; MediaItemsListView.LayoutTo(new Rectangle(0, _currentGridY, Width, Height)); } break; default: break; } }
protected override void OnDisappearing() { base.OnDisappearing(); if (MediaItemsListView != null) { MediaItemsListView.RemoveAllGestureRecognizers(); } }
protected override void LayoutChildren(double x, double y, double width, double height) { var complete = Math.Min(1, height / (ParentHeight)); MediaItemsListView.Opacity = complete; TitleLabel.Opacity = complete; MainLayout.RowDefinitions [0].Height = 40 * complete; MainLayout.RowDefinitions [1].Height = MinimumHeightRequest + (160 * complete); // Debug.WriteLine ("complete {0} height {1} ph{2}", complete, height, ParentHeight); base.LayoutChildren(x, y, width, height); MediaItemsListView.Layout(new Rectangle(0, MediaItemsListView.Bounds.Y, width, MediaItemsListView.Bounds.Height)); }
void MainLayout_OnLayoutChildren(double x, double y, double width, double height) { MediaItemsListView.Layout(new Rectangle(0, 0, Width, Height)); if (!_didLayoutContainer) { _contentBounds.Y = height - 100; _contentBounds.X = width - 160; _contentBounds.Width = 160; _contentBounds.Height = 100; _didLayoutContainer = true; } PageContainer.Layout(_contentBounds); }
public GestureScrollListExample() { InitializeComponent(); MainLayout.OnLayoutChildren += MainLayout_OnLayoutChildren; MediaItemsListView.ItemsSource = DataProvider.GetMediaItems(); _panGesture = new PanGestureRecognizer(); _panGesture.OnAction += Gesture_OnAction; _panGesture.IsConsumingTouchesInParallel = true; // _panGesture.CancelsTouchesInView = true; // _panGesture.DelaysTouches = true; // _panGesture.OnGestureShouldBeginDelegate += OnGestureShouldBegin; MediaItemsListView.AddGestureRecognizer(_panGesture); MediaItemsListView.OnScroll += MediaItemsListView_OnScroll; }
void MainLayout_OnLayoutChildren(double x, double y, double width, double height) { MediaItemsListView.Layout(new Rectangle(0, _currentGridY, Width, Height)); Details.Layout(new Rectangle(0, 0, Width, 400)); }