#1,005 – Enabling Deferred Scrolling for Better Performance

By default, when you drag the thumb portion of a scrollbar, the content being scrolled updates as you move the thumb.  In some cases, this can make scrolling slow if the content being scrolled takes a long time to update.

You can improve the performance of the user interface while scrolling by telling the associated ScrollViewer not to scroll the content until you let go of the scrollbar’s thumb.  This is known as deferred scrolling.

You can enable deferred scrolling by setting the IsDeferredScrollingEnabled property of the associated ScrollViewer to true.  Below is an example of doing this for a ListBox.

        <ListBox ItemsSource="{Binding ActorList}" Width="300"
                 ScrollViewer.IsDeferredScrollingEnabled="True">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="{Binding Image}" Height="100"/>
                        <StackPanel Margin="10,0">
                            <TextBlock Text="{Binding FullName}" FontWeight="Bold" />
                            <TextBlock Text="{Binding Dates}"/>
                            <TextBlock Text="{Binding KnownFor}" FontStyle="Italic"/>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a comment