Step 1- First let create an UI



Code Snippet For UI(XAML)

  1. <phone:PhoneApplicationPage
  2. x:Class="Web_Service.MainPage"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
  6. xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
  7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9. xmlns:cxi="clr-namespace:Web_Service"
  10. mc:Ignorable="d"
  11. FontFamily="{StaticResource PhoneFontFamilyNormal}"
  12. FontSize="{StaticResource PhoneFontSizeNormal}"
  13. Foreground="{StaticResource PhoneForegroundBrush}"
  14. SupportedOrientations="Portrait" Orientation="Portrait"
  15. shell:SystemTray.IsVisible="False">
  16. <phone:PhoneApplicationPage.Resources>
  17. <Storyboard x:Name="FadeinTransistion">
  18. <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="textBlock">
  19. <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
  20. <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0.2"/>
  21. <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0.4"/>
  22. <EasingDoubleKeyFrame KeyTime="0:0:1.5" Value="0.6"/>
  23. <EasingDoubleKeyFrame KeyTime="0:0:2" Value="0.8"/>
  24. <EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="1"/>
  25. </DoubleAnimationUsingKeyFrames>
  26. </Storyboard>
  27. </phone:PhoneApplicationPage.Resources>
  28. <!--LayoutRoot is the root grid where all page content is placed-->
  29. <Grid x:Name="LayoutRoot" Background=" #336699">
  30. <Grid.RowDefinitions>
  31. <RowDefinition Height="800"/>
  32. </Grid.RowDefinitions>
  33. <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,308">
  34. <TextBlock x:Name="textBlock" Text="Vibrate" Margin="9,20,0,0" Style="{StaticResource PhoneTextAccentStyle}" FontFamily="Fonts\abeatbyKai.ttf#abeatbyKai" Height="85" Foreground="White" FontSize="70" />
  35. </StackPanel>
  36. <!--ContentPanel - place additional content here-->
  37. <Grid x:Name="ContentPanel" Margin="0,520,0,0"/>
  38. <Button Content="Vibrate Me !" Click="Vibrater_Click" HorizontalAlignment="Left" Margin="100,395,0,0" VerticalAlignment="Top" Width="285"/>
  39. </Grid>
  40. </phone:PhoneApplicationPage>
Step 2



Right Click Vibrater_Click>Navigate To Event handler



So now Press “F5” to Debug . Its Done

Note: You can change how many seconds you want to vibrate in the Timespan(1000=1sec).

Comment below for any further doubts.