We are going to use MessagingCenter in Xamarin.Forms, which allows us to send an object along with the message. We need to create a class that can carry the information we want to pass. Let's set this up by going through the following steps:
- In the WhackABox project root, create a new class called GameStats.cs.
- Add the following code to the class:
public class GameStats
{
public int NumberOfPlanes { get; set; }
public int NumberOfBoxes { get; set; }
}
The class will be a simple data carrier that indicates how many planes and boxes we have.