How to Create UWP App Part-1
![]() |
| UWP |
How to Create UWP App Part- 1
This is Series of posts in which i am going to explain how UWP(Universal Windows Platform) Apps are created.
Now-a-days all are developing Apps for Android and IOS but there are some hardcore windows fans like me who still use Windows Phone so for them there is need for Apps to be develop.So this tutorial is for some one who want to learn Windows App development so that they want to develop apps for windows and become Windows Developer and to rescue windows fans!!. Lets dive into development
Before actually developing there are few things you need to know like UWP,C#,XAML,Visual Studio etc.
Now what is UWP?
UWP is new architecture of Windows apps i.e if you develop app for Windows Phone then you are developing app for all the platforms windows is running from IOT devices to Hololens without additional code changes.UWP architecture is primary focus of Windows 10 OS so that irrespective of the device same app runs across all your device to give true cross-device experience.
C#:
C# is a programming language created by Microsoft and most of its features derived from C.It is used to provide functionality in Apps like clicking button function,list selection function etc. of course there are other languages to develop windows app like Visual Basic,F# etc. but C# is most widely used language.
To Learn C# visit:MVA
XAML:
XAML is Language which uses XML based syntax designed by Microsoft.It is used to provide visuals like text,buttons,list views,Images etc. to Windows Apps. It works with C# behind to provide functionality to visuals. Its like HTML for Windows Apps and C# is like JavaScript like in Web designing.
To Learn XAML visit:Channel 9
Visual Studio:
Have you ever done c programming then you may know about compilers. Visual Studio is something like that but it is IDE i.e it has visual debugger to view your app live and to debug your apps. It is a Program which has Compilers,Linkers,debuggers etc. to develop Windows Apps. Here we use Visual Studio Community Edition since it is free. To installation tutorial see below.
In addition to above there are some things like API , .NET Framework , SDK etc. to know.
Steps to Install Visual Studio:
1. Goto this link and download Visual Studio Community Edition.
2. Run the setup and select Visual Studio Community Edition.
3. Check Universal Windows Section
![]() |
| Visual Studio Installation. |
4.Complete the installation it will take few hours depending on Internet speed. Yes Installation takes hours and size is also huge like 30-50GB !!!
5. Fire Visual Studio and start developing (see below).
Creating new project:
1.Select new project in File menu
![]() |
| Select new project in File Menu |
2.Select Template > Visual C# > Windows Universal in dialog.
![]() |
| Blank app |
Here Select Blank App in right because we are starting from scratch. Give any name for project and choose any folder to put the source code of App we are developing.
5. Click on MainPage.xaml in Solution explorer if it is not visible goto View > Solution Explorer and examine the Visual Studio for some time to know about it.
![]() |
| Work Space |
Here
1. Solution explorer where all our source code appears.
2. XAML designer where we can view how our apps look like
3.XAML Editor where we edit XAML code to get visuals
4. Properties tab. This tab shows properties for selected tab.
6.Now Paste following code in XAML Editor:
<MediaPlayerElement AreTransportControlsEnabled="True" Name="Player"></MediaPlayerElement>
<Button Name="Open" Content="Open" Click="Open_Click"></Button>
<Button Name="Open" Content="Open" Click="Open_Click"></Button>
In this code we are first adding media-player to play a song we select and button to select a song
MediaPlayerElement is a tag in XAML which will take a file like song,video and plays it. it has some things like Name,AretransportControlsEnabled which are called attributes.
first one is used to name our player and second is used to show play/pause controls for media player.
Button is a tag used to create a button by clicking it we will open a file picker to select a song and play it.Name attribute is same as above,Content is used to show text on button,Click is event that contains function to execute when button is clicked.
![]() | ||||||||||||||||||||
| CODE |
Copy and paste this code
Windows.Storage.Pickers.FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.FileTypeFilter.Add(".mp3");
picker.FileTypeFilter.Add(".wmv");
picker.FileTypeFilter.Add(".mp4");
Windows.Storage.StorageFile song = await picker.PickSingleFileAsync();
if (song !=null)
{
Player.Source = MediaSource.CreateFromStorageFile(song);
Player.MediaPlayer.Play();
}
1. async keyword is added to make Open_Click() method to make it asynchronous i.e function which runs on it own like simultaneously.
2.This code will create FILE Picker which is used to select a song.
3. This lines of codes add filetypes that can be selected by File Picker.
4.This code opens picker and wait for a single song to be pick.
5.This code sets MediaPlayerElement Source to selected file song and starts playing it. Hurry !!!!!!!!!!!!!!!!!!!!! We have developed a APP to play a song selected.







Comments
Post a Comment