How to get 1 button to do 2 things at once.

Category: windows phone howto

Question

ken roberts1 on Sat, 16 Jun 2012 09:16:33


How to do two different things from the one click?
The xaml code is,
<MediaElement x:Name="media" Source="a.wma"
AutoPlay="False" Stretch="Fill" Volume="1"
Margin="0,0,480,800" MediaEnded="media_MediaEnded" />
<Button Name="Button1" Content="Next Page"
Height="72" Margin="116,675,84,21"/>
The vb code is,
Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click
media.Play()
End Sub
Private Sub media_MediaEnded(sender As System.Object, e As System.Windows.RoutedEventArgs)
NavigationService.Navigate(New Uri("/Page1.xaml", UriKind.Relative))
End Sub
How it dose two different things,
First the a.wma soundeffect plays once button is clicked,
Second the page Navigation changes once the sound stops playing..
Very Important
No sound or video will play without doing this.

To add a video file to your application, perform the following actions in Visual Studio:
On the Project menu, select Add Existing Item.
Select the desired video file, then click Add.
In Solution Explorer, select the image file that was added.
In the Properties window, change the Build Action property to Resource.