My Problem
I have a problem with developing a touch friendly UI for an embedded device.
Using the standard ListBox from WPF 4.0, which supports touch events and touch scrolling out of the box, the touch scrolling performance is way worse than scrolling via pulling the scrollbar with a mouse.
Most notably, when starting a scroll flick, the scrolling stutters for a fraction of a second, but enough to feel bad and make flicks almost unusable (the gesture is complete when the stuttering stops, resulting in no, or minimal response).
As a reference I used touch scrolling in Windows Explorer, which has no problems and reacts smoothly.
Why is touch scrolling for the ListBox that much worse than both scrolling with the mouse, and touch scrolling in the explorer?
My Test Code
<ListBox x:Name="listBox"
ScrollViewer.CanContentScroll="False">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type Brush}">
<StackPanel Orientation="Horizontal">
<Rectangle Width="100"
Height="100"
Fill="{Binding}" />
<TextBlock Text="{Binding Color}" FontSize="36" Margin="20"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The ItemsSource is set to an IEnumerable<Brush> containing all 141 brushes in System.Windows.Media.Brushes.
What I tried
I’ve played around with some configuration options without avail. I tried
VirtualizingStackPanel.IsVirtualizingboth true and false- Reducing the number of brushes to 20
- Explicitly settings the ItemsPanel to a VirtualizingStackPanel
ScrollViewer.CanContentScroll="True"(hard to jugde then, but I think the problem persists)
Since mouse scrolling is fine, I didn’t really expect these to help any, but.. well.. I tried. =)
As a workaround I reimplemented the touch scrolling using the
TouchXevents. This works as smoothly as can be expected from the system its running on.