Beispiel #1
0
        private void PhotosPage_Loaded(object sender, RoutedEventArgs args)
        {
            //var scrollViewer = ItemsGridView.GetScrollViewer();
            //if (scrollViewer == null) return;
            //scrollViewer.LayoutUpdated += (s, _) =>
            //{
            //    Debug.WriteLine(scrollViewer.VerticalOffset);
            //    //scrollViewer.ScrollableHeight == scrollViewer.VerticalOffset //到底
            //};

            //return;
            var scrollViewer = ItemsGridView.FindDescendant <ScrollViewer>();
            var scrollbars   = scrollViewer.GetDescendantsOfType <ScrollBar>().ToList();
            var verticalBar  = scrollbars.FirstOrDefault(x => x.Orientation == Orientation.Vertical);

            scrollViewer.ViewChanged += (_, e) =>
            {
                if (e.IsIntermediate)
                {
                    return;
                }
                TopAppBarButton.Visibility =
                    scrollViewer.VerticalOffset == 0 ?
                    Visibility.Collapsed :
                    Visibility.Visible;
            };
            TopAppBarButton.Click += (s, e) =>
            {
                scrollViewer.ChangeView(null, 0, null, false);
            };
            RefreshAppBarButton.Click += AppBarButton_Click;
        }