Windows Phone 7-Shake It Like You Mean It!
Shake Gesture Library Now Available
When developing applications for Windows Phone 7 you have access to vast amounts of information about the device through its sensors. One of these is the accelerometer which can give you information on where the device is moving within 3D space, this can be utilised in many different ways, the most prominent of these being in gaming.
There are however many other ways to use this information, you may want a user to be able to shake their device to update their twitter list instead of pressing a button, or many other implementations like this.
The Magic Eight Ball App
To show how easy this is to use, lets write a simple app, I want to ask my eight ball a question, shake my device and have an answer appear.
- Create a new Windows Phone 7 project in Visual Studio:
- Create a UI which has an image of an eight ball with a TextBlock hovering over the top to show the answer.
- Add initialisation of a List<string> to hold our responses
- In the Loaded event of our page add the handling for the shake gesture using the Shake Gesture Library.
That’s our App done, your Windows Phone 7 can now impart you with the knowledge of the Universe. Go Shake!!