How can I combine Touch and Mouse Event Handlers without producing duplicate behavior?
<p>I am working on a WPF application which is being used on a Touch Screen Tablet. I develop using VS2015 IDE and I use my Mouse to debug.</p>

<p>I must handle buttons' <code>down</code> and <code>up</code> events to execute certain tasks. I use <code>PreviewMouse</code> and <code>PreviewTouch</code> event handlers and I have a problem in every case I use:</p>

<ul>
<li><p><strong>Case 1:</strong> Using <code>PreviewMouseDown</code>,<code>PreviewMouseUp</code>,<code>PreviewTouchDown</code> and <code>PreviewTouchUp</code>. For each button, I need to duplicate my code to include separate Touch and Mouse Event handlers <em>but</em> the exact same functionality. I do this for me to be able to use the Application (Mouse) and for the the user to use it (Touch). <strong>Problem</strong>: Touch Event Handlers executes Mouse Event Handlers; Causing the application to duplicate the behavior. Ex: A button that increments <code>x</code> by one, will increment by one if you "Click" it but increment by two if you "Touch" it.</p></li>
<li><p><strong>Case 2:</strong> Using <code>Click</code>, <code>PreviewMouseUp</code> and <code>PreviewTouchUp</code>. <strong>Problem:</strong> The <code>PreviewTouchUp</code> and <code>PreviewMouseUp</code> do not get called on <em>Mouse Click</em>.</p></li>
<li><p><strong>Case 3:</strong> Create a method for each button and call it from both Touch and Mouse events like <a href="https://stackoverflow.com/questions/11245551/how-to-get-touchscreen-to-use-mouse-events-instead-of-touch-events-in-c-sharp-ap">How to get Touchscreen to use Mouse Events</a>. <strong>Problem:</strong> Duplicate behavior (method gets called twice)</p></li>
<li><p><strong>Case 4:</strong> Remove all Touch events since <code>PreviewMouseDown</code> and <code>PreviewMouseUp</code> are being executed on any Touch. The behavior works but I need to Touch certain positions on the button in order for it to execute. (Transparency? I must touch exactly one position - like a mouse?)</p></li>
<li><p><strong>Case 5:</strong> Using <code>MouseUp</code> and <code>MouseDown</code> instead of <code>Preview</code>. Didn't work on Touch at all, touching any position on the button.</p></li>
</ul>

<p>I want something similar to this <a href="https://social.msdn.microsoft.com/Forums/en-US/9b05e550-19c0-46a2-b19c-40f40c8bf0ec/prevent-a-wpf-application-to-interpret-touch-events-as-mouse-events?forum=wpf" rel="nofollow noreferrer">Prevent a WPF application to interpret touch events as mouse events</a> but only on the tablet. I still need to use my mouse in my environment. How can I fix that?</p>

<p><strong>Button sample XAML:</strong></p>

<pre><code>&lt;Button x:Name="locationScrollUpButton" Margin="0,5,5,0" Background="Transparent" Padding="0" Grid.Row="1" Grid.Column="1" PreviewMouseUp="locationScrollUpButton_PreviewMouseUp" PreviewMouseDown="locationScrollUpButton_PreviewMouseDown" BorderThickness="0" PreviewTouchDown="locationScrollUpButton_PreviewTouchDown" PreviewTouchUp="locationScrollUpButton_PreviewTouchUp" &gt;
    &lt;StackPanel&gt;
        &lt;TextBlock x:Name="locationUpButtonText" Text="Up" FontSize="13" Margin="0,2,0,4" HorizontalAlignment="Center" VerticalAlignment="Center"/&gt;
        &lt;Image x:Name="locationUpButtonImage" Source="/ProjectName;component/Resources/CaptureView/Location-Scroll-Up-White.png" Width="55" Height="60"/&gt;
    &lt;/StackPanel&gt;
&lt;/Button&gt;
</code></pre>