WPF ListViewItem events not firing properly on Touchscreen RRS feed

  • Question

    <Window x:Class="WpfApplication2.MainWindow"
             Title="MainWindow" Height="550" Width="525">
                 <RowDefinition Height="4*"/>
             <TextBox Name="TextBox" VerticalContentAlignment="Center" FontSize="30" ></TextBox>
             <ListView Grid.ColumnSpan="6"  Grid.Row="1"
                         <WrapPanel Orientation="Horizontal" />
                     <Style TargetType="{x:Type ListViewItem}">
                         <Setter Property="Width" Value="200"/>
                         <Setter Property="Height" Value="200"/>
                         <EventSetter Event="PreviewMouseDown" Handler="button_Click" />
             <Button Content="Close" Grid.Column="0" Grid.Row="2" Click="Button_Click_1" ></Button>

    // code behind

    public MainWindow()
                 for (int i = 0; i < 10; i++)
     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.

    Wednesday, May 23, 2018 3:08 PM

All replies

  • Hi Mockingbird11,

    >>For example, if I press 10 buttons in my list view in a row, maybe 7 touches will register and 3 touches won't.

    I can just see the UI text change has a delay, because you are accessing UI object through code behind, we would suggestion using Dispatcher.Invoke method:

    private void Button_Click(object sender, RoutedEventArgs e)
                Application.Current.Dispatcher.Invoke(new Action(() => { this.TextBox.Text = this.c++.ToString(); }));

    And have you tested whether the TouchDown method works well on your machine? If the result is the same, the hardware/driver issue is also a possible reason.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 24, 2018 2:41 AM
  • <configuration> <runtime> <AppContextSwitchOverrides value="Switch.System.Windows.Input.Stylus.DisableStylusAndTouchSupport=true" /> </runtime> </configuration>

    Finally found the answer. I put the above in my config file, and all working.

    Thursday, May 24, 2018 7:29 PM