Introduction
Yesterday I created a demo Windows Phone 8 application. I want to share my first small app with you all. This article explains how to create your first Windows 8 Mobile App. This article may be helpful for beginners in Windows Store app development.
First of all, you should have a proper machine configuration with SDK for Windows app development.
Setting up a development environment
Use the following procedure before starting application development
- Install Windows 8 Mobile SDK.
- Enable Hyper-V from the Control Panel by selecting "Programs and Features" -> "Turn Windows features on or off".
- The following image is for reference
- Enable virtualization from BIOS settings -> "Advanced options".
Creating the windows 8 phone application
To create this application I used Visual Studio 2013 and Windows 8 64 bit. In this application, I created two buttons, Play and Stop.
- Play: start music
- Stop: stop the music
Use the following procedure to create the Windows 8 Phone Application.
- Open Visual Studio 2013
- "File" -> "New" -> "Project..."
- Under "Visual C#" then select "Windows Phone"
- Choose "Windows Phone app"
- Enter the name "Music Player"
You will now see the following screen.
Adding buttons and media element
You can now change your header from the Stack panel. I changed my application to "Nokia Music Player" and set the page name to "Music Player". Then add two buttons, Play and Stop, using the following markup in the Grid Content Panel.
<Button Height="200" Name="Play" Width="200" Background="blue" HorizontalAlignment="Left" VerticalAlignment="Top" Click="Play_Click">Play Song</Button>
<Button Height="200" Name="Stop" Width="200" Background="blue" HorizontalAlignment="Right" VerticalAlignment="Top" Click="Stop_Click">Stop</Button>
<MediaElement x:Name="QuickMediaElement" Source="/Assets/Sound/song.mp3" AutoPlay="False"></MediaElement>
I created two buttons and their Click event. I added a Media element tag that contains a source (an mp3 song) with song.mp3 for the Assets/sound folder.
To generate a Click event of the buttons write "Click" and it will show you a suggestion as in the following.
Handling button click events
Now click on the New Event Handler. It will create a Play_Click and Stop_Click on MainPage.xaml.cs page automatically. Now on the cs page enter the following. To Play
private void Play_Click(object sender, RoutedEventArgs e)
{
QuickMediaElement.Play();
}
To Stop
private void Stop_Click(object sender, RoutedEventArgs e)
{
QuickMediaElement.Stop();
}
Your First Demo application is ready now. Run the Application using the Emulator. When you start your emulator the first time it will take some time.
Here is your first Windows 8 Mobile Application. Enjoy your own Nokia Music Player.
Summary
In this article, we learned about Create First Windows 8 Mobile Application Development.