The last line of code to add will wire up the StatsUpdated handler to an incoming message. Let's set this up by going through the following steps:
- In the WhackABox project, open the MainPage.xaml.cs file.
- In the constructor, add the line of code that is highlighted in bold in the following code snippet:
public MainPage()
{
InitializeComponent();
MessagingCenter.Subscribe<Game, GameStats>(this,
"stats_updated", StatsUpdated);
}
This line of code hooks up an incoming message with the content stats_updated to the StatsUpdated method. Now, run the game and go out into the world to hunt down those boxes!
The completed app looks something like the following screenshot, with spinning boxes popping up at random locations: