I have an application that converts mouse events into touch ones so I can use inertia scrolling and other touch features. That code is in the selected answer here:
WPF: Is there a possibility to "route" ordinary mouse events to touch events in Windows 7
The problem I'm having with my ListBox
is while I'm flick scrolling, it selects items. Normally touch devices do not select a ListBox
item while it's scrolling. What am I missing here?
Here is the xaml I'm using:
<Window x:Class="ScrollingTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="525">
<Grid>
<ListBox x:Name="testListBox"
VirtualizingPanel.ScrollUnit="Pixel"
SelectionMode="Single">
<ListBox.ItemTemplate>
<DataTemplate>
<Border CornerRadius="3" Height="60" Width="480" Background="LightGray" Margin="1">
<Label Content="{Binding}"/>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
Code behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MouseTouchDevice.RegisterEvents(this);
for (int i = 0; i < 300; i++)
{
testListBox.Items.Add("test " + i.ToString());
}
}
}