O'Reilly logo

Mastering Xamarin UI Development - Second Edition by Steven F. Daniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling touch events in the Game Board user interface

In this section, we will look at implementing the necessary logic in our ViewController class and learn how to work with the UITouch class to handle touch events to determine when a Game Tile has been tapped on the Game Board.

Let's start by modifying the ViewController class for our SlidingTiles app by performing the following steps:

  1. Ensure that the ViewController.cs file is currently displayed in the code editor.
  2. Next, underneath the startNewGame instance method, we need to create and implement an event method called TouchesEnded that will be called whenever a touch has happened in the game board view; enter the following code snippet:
 #region 7 - Handling touch events in the Game ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required