Search code examples
c#wpfxamlpixelsense

How to best disable multitouch on buttons in WPF?


I am working on a Surface application and I have a problem with multiple buttons getting pressed at the same time.

I have a menu control with a few buttons. Some of them are bound to Commands that make the hosting window fade out the menu control and run something else, while some are just hooked up to EventTriggers that fade through different view-states of the menu control. The problem is that on Surface you can even press 10 buttons at the same time, which causes freak effects, so I would like to disable all buttons on my control when one is pressed indefinitely or until fade animations are complete and possibly prevent more than one button to go into pressed state.

Any neat ideas or should I just handle all touch inputs and state machine manually?


Solution

  • If you bind to a custom command you can control this via

    bool CanExecute
    

    Returning

    false
    

    makes the button not press able. Those without commands must be handled traditionally.