Evorlor
Evorlor

Reputation: 7553

Check if Screen is Touched

In Windows Phone 8.1, how can I trigger a method every time the screen (with the exception of the Command Bar or other Buttons) is touched?

I could use a massive Button, but that just seems...terrible.

I will have some TextBlocks on the screen, and I still want the method to trigger even if they are the things being touched.

So basically, I am looking for a method that will fire if anything that is not a Button is touched.

I have been looking at the massive Windows Phone API, but it is challenging, as I am not really sure what I am looking for.

Upvotes: 0

Views: 59

Answers (1)

Romasz
Romasz

Reputation: 29792

I think you can make use of PointerEntered event of CoreWindow:

// in MainPage constructor for example:
Window.Current.CoreWindow.PointerEntered += CoreWindow_PointerEntered;

private void CoreWindow_PointerEntered(CoreWindow sender, PointerEventArgs args)
{
    // do your code here
    Debug.WriteLine("Screen touched");
}

Note also that you have couple of more nice events to play with.

Upvotes: 1

Related Questions