Share via

WPF touch event in screen not working with UserControl

Rosa Tarraga 1 Reputation point
2021-08-18T11:23:36.677+00:00

We are developing a WPF application. We use .net4.7 but we have tested it with .net5 and our problem persists.

We have some different elements (buttons, input text...) and sometimes they have to show a "popup" (as a messagebox).

So, our problem happens when we have a list item (listview from windows control) and we want to show a MessageBox; if we do the same thing with a button instead of a list item, it works.

If we manage the MessageBox with the mouse, everything works perfectly, but it we manage with our touch screen, we need to click 10 times to get it working.

This is our list in xml (it comes from a template).

<lists:VehicleList Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3"
                               DataContext="{Binding Path=DataContext, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type local:StepSelect}}}"/>

This is what we show through the ViewModel with result yes/no and which buttons we must click 10 times with the touch screen:

MessageBox.ShowDialog(InfoMessages.driverContinue, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { NavigateForward(this, res);

Any idea?

Thanks in advance :)

PS: We use Windows 10.

Edited:

Found that the problem occurs when I do MessageBox.ShowDialog(whatever); but it does not happen when I do MessageBox.Show(whatever);

Any idea?

Developer technologies | Windows Presentation Foundation
Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.


2 answers

Sort by: Most helpful
  1. cheong00 3,491 Reputation points Volunteer Moderator
    2021-08-19T08:35:09.687+00:00

    Try follow the advice at the bottom of this issue in Github for WPF.

    Was this answer helpful?


  2. Bineesh Kavungal Babu 1 Reputation point
    2021-08-19T07:25:35.823+00:00

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.