Supress auto scroll when content size changes in ScrollViewer RRS feed

  • Question

  • I've placed a gridview inside of a HubSection (who's parent is the Hub's ScrollViewer).

    • When the scroll bar's to the left, it stays in place after I add additional items to the gridview.
    • If I scroll more than 50%, and then add items, the scroll position is adjusted to show the newly added items.
    • Likewise, if I scroll to the end, the scrollbar 'sticks' to the end when items are added.

    Is there anyway to disable this behavior completely and just have the scrollbar remain in place (just as it does when I'm scrolled to the left), without using ScrollToHorizontalOffset to manually set the scroll position after items are added?

    Test code below:

       <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <Hub Header="Hub">
                <HubSection Header="HubSection 0" Width="686">
                <HubSection x:Name="hubSection1" Header="HubSection 1">
                            <GridView x:Name="gridView" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Loaded="gridView_Loaded" >
                                    <DataTemplate x:Key="GridViewItemTemplate">
                                        <Grid Width="100">
                                            <TextBlock HorizontalAlignment="Stretch" TextWrapping="Wrap" Text="{Binding}" VerticalAlignment="Top" FontSize="72"/>
                                    <StaticResource ResourceKey="GridViewItemTemplate"/>
            <Button Content="Add items" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="180,51,0,0" Height="60" Width="308" Click="Button_Click"/>

    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    namespace App2
        public sealed partial class MainPage : Page
            private GridView _gridView { get; set; }
            private int count = 0;
            public MainPage()
            private void gridView_Loaded(object sender, RoutedEventArgs e)
                _gridView = (GridView) sender;
                //initial items
                for (int i = 0; i < 100; i++)
            private void Button_Click(object sender, RoutedEventArgs e)
                for (int i = 0; i < 100; i++)

    Thursday, December 26, 2013 7:52 PM


All replies