WPF 3.5 SP1の新機能 - IsDeferredScrollingEnabled

WPF 3.5 SP1 Feature: Non-live Scrolling – Vincent Sibal's Blog



WPF 3.5 SP1 BetaのScrollViewerには、IsDeferredScrollingEnabledプロパティが追加されています。このプロパティをTrueに設定することで、いわゆる遅延スクロールができるようになりました。下記は、ListBoxの例になります。


Visual Basic

Class Window1
 
    Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
        Dim ListData As New ObjectModel.ObservableCollection(Of String)
        For i = 0 To 99
            ListData.Add("テストデータ" + i.ToString())
        Next
        ListBox1.ItemsSource = ListData
        ListBox2.ItemsSource = ListData
    End Sub
 
End Class


XAML
<Window x:Class="Window1"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   Title="Window1" Height="300" Width="300" Name="Window1">
    <UniformGrid Columns="2">
        <ListBox Name="ListBox1" ScrollViewer.IsDeferredScrollingEnabled="False"/>
        <ListBox Name="ListBox2" ScrollViewer.IsDeferredScrollingEnabled="True"/>
    </UniformGrid>
</Window>





IsDeferredScrollingEnabledプロパティ値がFalseの場合、スクロールバーの移動に対してコンテンツは即時スクロールします。これが既定の動作です。IsDeferredScrollingEnabledプロパティ値をTrueに設定した場合、スクロールバーを移動してもドラッグ中はコンテンツがスクロールしません。ドロップしたときに初めてスクロールするという動作になります。


遅延スクロールは、非常に大量のデータを表示させる場合に有用であるとのことです。


ちなみにSPREAD for .NET 3.0J Windows Forms Editionは、デフォルトのスクロール動作がこの遅延スクロールとなっています。即時スクロール動作とするには、ScrollBarTrackPolicyプロパティをVerticalやHorizontal、Bothなどに設定します。