HOW TO HANDLE/CAPTURE A LONG PRESS IN WINDOWS STORE APPS

jacob rasel

Total Post:88

Points:616
Posted by  jacob rasel
 887  View(s)
Ratings:
Rate this:

Could anyone tell me how to capture a long press for a windows store app in C#? I can used a "tapped" gesture no problem but when I replace  TappedRoutedEventArgs with HoldingRoutedEvent it just doesn't register a holding gesture. I'm testing this with my laptop so could it be that it doesn't recognize a mouse holding event?


I'm assuming there's similar functionality for the windows phone 7 but they're mostly for Silverlight which isn't used for Windows 8. Any links/examples would be a great help!

  1. Mayank Tripathi

    Post:397

    Points:3117
    Re: How to handle/capture a long press in windows store apps

    Use the Holding Event:

    XAML:

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Holding="Grid_Holding_1">
    </Grid>

    CS:

    private void Grid_Holding_1(object sender, HoldingRoutedEventArgs e)

    {
        Debug.WriteLine("You held at" + DateTime.Now.ToString());
    }

    You are correct about the mouse not firing the holding event. Run it in the simulator and then you can use the "Basic Touch Mode" to simulate the hold.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!