WPF and MVVM – Touch Device needs to tap twice on button to fire command.

Touch devices may need to tap twice on a button to fire command.

This always happens on my end when the button is located alongside a textbox or other elements on a user or windows control.

The fix.

1. Add a touch down event for the event in the xaml.

2. Fire command manually

            MapEntity commandParameter = (MapEntity)(((Button)sender).CommandParameter);

            var viewModel = (FindADISViewModel)DataContext;
            if (viewModel.OpenDIS.CanExecute(commandParameter))
                viewModel.OpenDIS.Execute(commandParameter);

It works!