<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowState="Maximized"
Title="MainWindow" Height="550" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="4*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Name="TextBox" VerticalContentAlignment="Center" FontSize="30" ></TextBox>
<ListView Grid.ColumnSpan="6" Grid.Row="1"
x:Name="GridControlProducts"
SelectionMode="Single"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Setter Property="Width" Value="200"/>
<Setter Property="Height" Value="200"/>
<EventSetter Event="PreviewMouseDown" Handler="button_Click" />
</Style>
</ListView.ItemContainerStyle>
</ListView>
<Button Content="Close" Grid.Column="0" Grid.Row="2" Click="Button_Click_1" ></Button>
</Grid>
</Window>
// code behind
public MainWindow()
{
InitializeComponent();
for (int i = 0; i < 10; i++)
{
this.GridControlProducts.Items.Add("Test");
}
}
private int c = 1;
private void button_Click(object sender, RoutedEventArgs e)
{
this.TextBox.Text = this.c++.ToString();
}
I have a WPF touchscreen application which contains a list of products in a list view template.
Using a mouse everything works as you would expect. However, on a touchscreen the touch events don't fire every time. For example, if I press 10 buttons in my list view in a row, maybe 7 touches will register and 3 touches won't.
If I touch a standard button on it's own, it's very responsive. The buttons in my template are not (very hit and miss).
I created a simple test application (see above) to test this, and the behaviour on my test app is the same.
When it doesn't register, the previously selected listviewitem is still selected, and the item I have selected that hasn't registered is a light blue (like when you hover over with a mouse)
Any help would be greatly appreciated.