Question

I'm trying to create some functionality where the App's AppBar will hide when I'm scrolling down an ItemsControl - I've attached an event handler on to the ScrollViewer but the problem I'm facing is that the functionality is very sensitive. What I mean by that is the app bar keeps showing and hiding when I'm moving up and down the list.

My Event Handler - I have a field called scrollPoint that stores that last scroll Vertical Offset.

private void pushScroll_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
        {
            var scrollViewer = (ScrollViewer)sender;

            if (scrollViewer.VerticalOffset < scrollPoint)
            {
                bottomBar.Visibility = Visibility.Visible;
            }
            else
            {
                bottomBar.Visibility = Visibility.Collapsed;
            }


            scrollPoint = scrollViewer.VerticalOffset;
        }

My ItemsControl Template

<ItemsControl.Template>
                    <ControlTemplate>
                        <ScrollViewer x:Name="pushScroll" VerticalScrollMode="Enabled" BringIntoViewOnFocusChange="True" ViewChanged="pushScroll_ViewChanged">
                            <ItemsPresenter />
                        </ScrollViewer>
                    </ControlTemplate>
                </ItemsControl.Template>
Was it helpful?

Solution

Have you thought about implementing a timer. So you have to be done scrolling for 1/2 a second before the App bar comes back. However, it disappears almost instantly when scrolling.

http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx

You might also want to look into an animation so it slides away and slides back.

OTHER TIPS

The problem with your solution is that when you scroll up the appbar will alwasy be hidden. did you tried IsIntermediate of the event args? It will be false when scroll stops scrolling and true when scroll reach at the end. try below code.

private async void scrollViewer_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
    {
        if (e.IsIntermediate)
        {
            this.BottomAppBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
        else
            this.BottomAppBar.Visibility = Windows.UI.Xaml.Visibility.Visible;

    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top