Programming the Windows 8 app: how it works
In this practical tip, we will show you the first steps when programming Windows apps using the example of a simple "Hello World" application. You will learn which programs you need and how to create your first app yourself.
Windows 8: Prepare for an HTML app
You can use various programming languages such as C ++, VB or HTML to program Windows apps. In this guide, we work with the C # language.
- First download "Visual Studio Express 2013 for Windows" for free.
- When you start for the first time, you will be asked to apply for a developer license. You need this to program Windows apps. Follow the on-screen instructions to get a license in minutes.
Programming the Windows app - creating the user interface
Once you have installed the software and obtained the license, you can start programming.
- After starting Visual Studio click on "File -> New Project".
- In the following window, select "Installed> Templates" in the left column and then "Visual C #". It is best to use "Blank App" as the template type. You can name the solution as you like, for example "HelloWorld". Clicking "OK" will create the project.
- You will then see the Solution Explorer on the left with all the pre-made files. Double click on the "MainPage.xaml" file. The c # code of the file is now displayed in the code field. Here you will find an area "".
- Write the following code before "":
- /// (displays a text block with the text)
- /// (creates an input field for the name)
- /// (Creates the button that performs the entry.)
- /// (creates the output field for the text)
- Note: The comments in brackets are for explanation only and are not part of the code.
Hello World - activate the button
After you have added the elements to the interface, you must of course decide what should happen when the button is pressed.
- Now switch to the "MainPage.xaml.cs" file.
- Here you write the code "private void Button_Click (object sender, RoutedEventArgs e) {greetingOutput.Text =" Hello, "+ nameInput.Text +"! ";}" Below the existing text. This code determines that the text contained in the input field and a "Hello" appear when the button is pressed.
So let your "Hello World" run
- To start your first own app, just press the F5 key.
The "For loop in C #" is a bit more advanced when programming with Visual Studio for Windows. We also have a tutorial for you.