My custom control should contains 1000000+ items. I've implemented the custom control based on ItemsControl. The source XAML of the control is:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:MyTestApplication.Behaviors"
xmlns:helpers="clr-namespace:MyTestApplication.Helpers"
xmlns:local="clr-namespace:MyTestApplication.Controls"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
<Style TargetType="{x:Type local:RowsWrapperControl}">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
<Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:RowsWrapperControl}">
<ScrollViewer x:Name="PART_ItemsScrollViewer"
Margin="{TemplateBinding Margin}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CanContentScroll="True"
HorizontalScrollBarVisibility="Disabled"
Padding="{TemplateBinding Padding}"
VerticalScrollBarVisibility="Hidden">
<i:Interaction.Behaviors>
<behaviors:ScrollViewerOffsetBehavior VerticalOffset="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=VerticalScrollOffset, Mode=OneWay}" />
</i:Interaction.Behaviors>
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
The virtualizing works good, but scrolling works only item-by-item, not pixel-by-pixel. I tried to set the CanContentScroll property to False , but it breaks the visualization. I found some helpful information here and here, but it takes no effect for me.
Any idea how to turn on the smooth scrolling?
I have .Net 4.5 installed on my PC, but the target platform is .Net 4.0.
UPDATE: The solution was found here.