Question

Is there any way to detect that the stylus eraser button is pressed on a WPF element?

Was it helpful?

Solution

The answer seems to be to detect if the pen is Inverted. http://msdn.microsoft.com/EN-US/library/ms607230(VS.110).aspx

(tested on Lenovo x61 tablet)

In MainWindow.Xaml

<TextBlock Name="textBox"
        Text="Hello World!" HorizontalAlignment="Center" VerticalAlignment="Center"
        StylusDown="TextBlock_StylusDown_1"/>

In MainWindow.Xaml.cs

 private void TextBlock_StylusDown_1(object sender, StylusDownEventArgs e)
    {
        if (e.Inverted)
            textBox.Text = "I've been erased";
        else
            textBox.Text = "Normal stylus";
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top