A little vibration added to your application can be just the haptic feedback needed. It turns out that vibration is absurdly easy to add; so much so that discussions of adding vibration typically come with the caveat that you want to use it sparingly; too much of a good thing can make for a very annoying application.
To see how to add vibration to an application, let’s start by creating a new application named Vibrate.
The UI is dead simple, just a button centered on MainPage.xaml,
<Button Content="Vibrate" Name="Vibrate" Height="100" Width="300"/>
The event handler for this button will call the Vibrate Controller’s Start method passing in a value for how long to vibrate. You’ll need to add a using statement for Microsoft.Devices.
void Vibrate_Click( object sender, RoutedEventArgs e ) { VibrateController.Default.Start( TimeSpan.FromMilliseconds( 200 ) ); }
That’s really all there is to it. Press the button, the phone vibrates. You can imagine using this in a game of course, but also for specific (and startling) feedback in other applications as well.
3 Responses to Vibrating the phone