In a WPF application running on Windows 8, TouchDown events always propagate to MouseLeftButton events. I don’t know why and want to avoid it.
Here is a complete code example:
Xaml
<Window x:Class="TestTouchAndMouse.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
Stylus.IsPressAndHoldEnabled="False">
<Canvas x:Name="MyCanvas" Background="White" IsManipulationEnabled="False">
<TextBox x:Name="TB" InkCanvas.Top="50" InkCanvas.Left="10" FontSize="20" />
</Canvas>
</Window>
WITH#
namespace TestTouchAndMouse
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MyCanvas.MouseLeftButtonDown += MyCanvas_MouseLeftButtonDown;
MyCanvas.MouseRightButtonDown += MyCanvas_MouseRightButtonDown;
MyCanvas.TouchDown += MyCanvas_TouchDown;
}
void MyCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
TB.Text = "MOUSE RIGHT !";
}
void MyCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
e.Handled = true;
TB.Text = "MOUSE LEFT !";
}
void MyCanvas_TouchDown(object sender, TouchEventArgs e)
{
e.Handled = true;
TB.Text = "TOUCH !";
}
}
}
On windows 7
- everything is working fine.
On windows 8
- MouseLeftButton or MouseRightButton events show "Left mouse!" or "Mouse is right!" as was expected.
- TouchDown events will be displayed very quickly "Touch!" and then the text will change to "Left mouse!".
source
share